int next ( ) throws IOException { prevChar = curChar ; checkState ( prevChar > - 1 ) ; if ( pos < buf . length ) { curChar = buf [ pos ++ ] ; } else { curChar = in . read ( ) ; } offset ++ ; /* * Handle line and col * lf=\n, cr=\r */ if ( curChar == ' ' || curChar == ' ' ) { if ( curChar == ' ' && prevChar == ' ' ) { //second char in a windows CR+LF } else { prevLine = line ; line ++ ; } } else if ( prevLine < line ) { col = 1 ; prevLine = line ; } else { if ( prevChar != 0 ) { col ++ ; } } return curChar ; }
Returns the next character in the stream and advances the readers position . If there are no more characters - 1 is returned the first time this method is invoked in that state ; multiple invocations at EOF will yield an IllegalStateException .