code: @Override
    public int read(byte b[], int off, int len) throws IOException {
      int leftover = buf_end - buf_pos;
      if (len <= leftover) {
        System.arraycopy(buffer, buf_pos, b, off, len);
        buf_pos += len;
        return len;
      }
      for (int i = 0; i < len; i++) {
        int c = this.read();
        if (c != -1) {
          b[off + i] = (byte) c;
        } else {
          return i;
        }
      }
      return len;
    }
docs: Reads the set number of bytes into the passed buffer.
  
  @param b The buffer to read the bytes into.
  @param off Byte offset within the file to start reading from
  @param len Number of bytes to read into the buffer.
  @return Number of bytes read.