code: @Override
    public int read(byte []buf, int offset, int len) throws IOException
    {
      int available = _available;
      
      // The chunk still has more data left
      if (available > 0) {
        len = Math.min(len, available);
  
        len = _next.read(buf, offset, len);
  
        if (len > 0) {
          _available -= len;
        }
      }
      // The chunk is done, so read the next chunk
      else if (available == 0) {
        _available = readChunkLength();
  
        // the new chunk has data
        if (_available > 0) {
          len = Math.min(len, _available);
  
          len = _next.read(buf, offset, len);
  
          if (len > 0)
            _available -= len;
        }
        // the new chunk is the last
        else {
          _available = -1;
          len = -1;
        }
      }
      else {
        len = -1;
      }
      
      return len;
    }
docs: Reads more data from the input stream.