public int read(){
  if (position >= document.getLength()) {
    return -1;
  }
  try {
    document.getText((int)position,1,segment);
    position++;
    return segment.array[segment.offset];
  }
 catch (  BadLocationException ble) {
    ble.printStackTrace();
    return -1;
  }
}

public int read ( ) { if ( position >= document . getLength ( ) ) { return - 1 ; } try { document . getText ( ( int ) position , 1 , segment ) ; position ++ ; return segment . array [ segment . offset ] ; } catch ( BadLocationException ble ) { ble . printStackTrace ( ) ; return - 1 ; } }
reads the single character at the current position in the document .
