code: @Override
      public int read (byte[] b, int off, int len) throws IOException {
  
          if (closed) {
              throw new IOException("Attempted read from closed stream.");
          }
  
          if (eof) {
              return -1;
          }
          if (pos >= chunkSize) {
              nextChunk();
              if (eof) {
                  return -1;
              }
          }
          len = Math.min(len, chunkSize - pos);
          int count = in.read(b, off, len);
          pos += count;
          return count;
      }
docs: Read some bytes from the stream.
  @param b The byte array that will hold the contents from the stream.
  @param off The offset into the byte array at which bytes will start to be
  placed.
  @param len the maximum number of bytes that can be returned.
  @return The number of bytes returned or -1 if the end of stream has been
  reached.
  @see java.io.InputStream#read(byte[], int, int)
  @throws IOException if an IO problem occurs.