code: public int read(CharBuffer buf, int length) throws IOException
    {
      int len = buf.length();
  
      buf.length(len + length);
      
      int readLength = read(buf.buffer(), len, length);
      
      if (readLength < 0) {
        buf.length(len);
      }
      else if (readLength < length) {
        buf.length(len + readLength);
      }
  
      return length;
    }
docs: Reads characters from the stream, appending to the character buffer.
  
  @param buf character buffer to fill
  @param length maximum number of characters to read
  @return number of characters read or -1 on end of file.