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)
| 891 | * @since 14.0 |
| 892 | */ |
| 893 | @CanIgnoreReturnValue // some processors won't return a useful result |
| 894 | @ParametricNullness |
| 895 | @J2ktIncompatible |
| 896 | public static <T extends @Nullable Object> T readBytes( |
| 897 | InputStream input, ByteProcessor<T> processor) throws IOException { |
| 898 | checkNotNull(input); |
| 899 | checkNotNull(processor); |
| 900 | |
| 901 | byte[] buf = createBuffer(); |
| 902 | int read; |
| 903 | do { |
| 904 | read = input.read(buf); |
| 905 | } while (read != -1 && processor.processBytes(buf, 0, read)); |
| 906 | return processor.getResult(); |
| 907 | } |
| 908 | |
| 909 | /** |
| 910 | * Reads some bytes from an input stream and stores them into the buffer array {@code b}. This |
no test coverage detected