@ Override public int read ( ) throws IOException { int nextChar = super . read ( ) ; // process the character if ( nextChar != - 1 ) { if ( nextChar == ' ' ) { m_line ++ ; pushColumn ( m_column ) ; m_column = 0 ; } else if ( nextChar == ' ' ) { int aheadChar = super . read ( ) ; // if the lookahead is not a newline combo, unread it if ( aheadChar != ' ' ) { // no need to unread it with line/offset update. unreadImpl ( aheadChar , false ) ; } m_line ++ ; pushColumn ( m_column ) ; m_column = 0 ; // normalize nextChar = ' ' ; } else { m_column ++ ; } m_consumed ++ ; } return nextChar ; }
Uses the push back implementation but normalizes newlines to \ n .