android/guava/src/com/google/common/io/ByteSource.java
@Beta
  @CanIgnoreReturnValue // some processors won't return a useful result
  public <T> T read(ByteProcessor<T> processor) throws IOException {
    checkNotNull(processor);

    Closer closer = Closer.create();
    try {
      InputStream in = closer.register(openStream());
      return ByteStreams.readBytes(in, processor);
    } catch (Throwable e) {
      throw closer.rethrow(e);
    } finally {
      closer.close();
    }
  }
@Beta
  @CanIgnoreReturnValue // some processors won't return a useful result
  public <T> T read(ByteProcessor<T> processor) throws IOException {
    checkNotNull(processor);

    Closer closer = Closer.create();
    try {
      InputStream in = closer.register(openStream());
      return ByteStreams.readBytes(in, processor);
    } catch (Throwable e) {
      throw closer.rethrow(e);
    } finally {
      closer.close();
    }
  }
Reads the contents of this byte source using the given {@code processor} to process bytes as
they are read. Stops when all bytes have been read or the consumer returns {@code false}.
Returns the result produced by the processor.

@throws IOException if an I/O error occurs while reading from this source or if {@code
processor} throws an {@code IOException}
@since 16.0