Process the bytes of the given input stream using the given processor. @param input the input stream to process @param processor the object to which to pass the bytes of the stream @return the result of the byte processor @throws IOException if an I/O error occurs @since 14.0
(InputStream input, ByteProcessor<T> processor)
| 811 | * @since 14.0 |
| 812 | */ |
| 813 | @CanIgnoreReturnValue // some processors won't return a useful result |
| 814 | public static <T> T readBytes(InputStream input, ByteProcessor<T> processor) throws IOException { |
| 815 | checkNotNull(input); |
| 816 | checkNotNull(processor); |
| 817 | |
| 818 | byte[] buf = createBuffer(); |
| 819 | int read; |
| 820 | do { |
| 821 | read = input.read(buf); |
| 822 | } while (read != -1 && processor.processBytes(buf, 0, read)); |
| 823 | return processor.getResult(); |
| 824 | } |
| 825 | |
| 826 | /** |
| 827 | * Reads some bytes from an input stream and stores them into the buffer array {@code b}. This |
no test coverage detected