code: private byte[] readChunk() throws Exception {
          if (isEndOfInput()) {
              return EMPTY_BYTE_ARRAY;
          }
  
          try {
              // transfer to buffer
              byte[] tmp = new byte[chunkSize];
              int readBytes = in.read(tmp);
              if (readBytes <= 0) {
                  return null;
              }
              byte[] buffer = new byte[readBytes];
              System.arraycopy(tmp, 0, buffer, 0, readBytes);
              offset += readBytes;
              return buffer;
          } catch (IOException e) {
              // Close the stream, and propagate the exception.
              IOUtils.closeQuietly(in);
              throw e;
          }
      }
docs: Reads a chunk.
  @return the read bytes, empty if we reached the end of the stream. The returned array has exactly the sisize
  of the chunk.
  @throws Exception if the stream cannot be read.