@ Override public int peek ( int offset ) throws IOException { long target = cursor + offset - 1 ; if ( target - end > size || target < end - size || target < 0 ) { throw new IllegalArgumentException ( "offset " + offset + " out of buffer" ) ; } if ( target >= end ) { int la = 0 ; while ( target >= end ) { int cc = read ( ) ; if ( cc == - 1 ) { if ( target + la == end ) { return - 1 ; } else { throw new IOException ( "eof" ) ; } } la ++ ; } rewind ( la ) ; } return get ( target ) ; }
get a char from input buffer .