@Override
  public int read(byte b[], int off, int len) throws IOException {
    if (b == null) {
      throw new NullPointerException();
    } else if (off < 0 || len < 0 || len > b.length - off) {
      throw new IndexOutOfBoundsException();
    } else if (len == 0) {
      return 0;
    }

    int startOff = off;
    while (len > 0 && loadData()) {
      int toRead = Math.min(len, currentChunk.remaining());
      currentChunk.get(b, off, toRead);
      len -= toRead;
      off += toRead;
      reportBytesRead(toRead);
    }

    int bytesRead = off - startOff;
    if (bytesRead <= 0) {
      bytesRead = -1;
    }
    return bytesRead;
  }
Create a ReadableStreamChannelInputStream with the given {@link ReadableStreamChannel}.
@param readableStreamChannel the {@link ReadableStreamChannel} that needs to be converted into an
{@link InputStream}.
ambry-commons/src/main/java/com/github/ambry/commons/ReadableStreamChannelInputStream.java