public String next ( ) throws IOException { String result ; int len ; Matcher matcher ; while ( true ) { matcher = format . separator . matcher ( buffer ) ; if ( matcher . find ( ) ) { len = matcher . end ( ) ; if ( buffer . start + len == buffer . end ) { // make sure we match the longest separator possible if ( buffer . isFull ( ) ) { buffer . grow ( ) ; } buffer . fill ( reader ) ; matcher = format . separator . matcher ( buffer ) ; if ( ! matcher . find ( ) ) { throw new IllegalStateException ( ) ; } len = matcher . end ( ) ; } result = new String ( buffer . chars , buffer . start , format . trim == LineFormat . Trim . NOTHING ? len : matcher . start ( ) ) ; buffer . start += len ; } else { if ( buffer . isFull ( ) ) { buffer . grow ( ) ; } if ( buffer . fill ( reader ) ) { continue ; } else { if ( buffer . isEmpty ( ) ) { // EOF return null ; } else { result = buffer . eat ( ) ; } } } // always bump, even if we don't return the line line ++ ; if ( format . trim == LineFormat . Trim . ALL ) { result = result . trim ( ) ; } if ( ! format . excludes . matcher ( result ) . matches ( ) ) { return result ; } } }
Never closes the underlying reader .