public int read(char cbuf[],int off,int len){
  int k;
  if (position >= document.getLength()) {
    return -1;
  }
  k=len;
  if ((position + k) >= document.getLength())   k=document.getLength() - (int)position;
  if (off + k >= cbuf.length)   k=cbuf.length - off;
  try {
    document.getText((int)position,k,segment);
    position+=k;
    System.arraycopy(segment.array,segment.offset,cbuf,off,k);
    return k;
  }
 catch (  BadLocationException ble) {
    return -1;
  }
}

public int read ( char cbuf [ ] , int off , int len ) { int k ; if ( position >= document . getLength ( ) ) { return - 1 ; } k = len ; if ( ( position + k ) >= document . getLength ( ) ) k = document . getLength ( ) - ( int ) position ; if ( off + k >= cbuf . length ) k = cbuf . length - off ; try { document . getText ( ( int ) position , k , segment ) ; position += k ; System . arraycopy ( segment . array , segment . offset , cbuf , off , k ) ; return k ; } catch ( BadLocationException ble ) { return - 1 ; } }
reads characters into a portion of an array .
