private boolean forwardMatch ( String match , boolean ignoreCase , boolean resetOnTrue ) throws IOException { Mark mark = reader . mark ( ) ; List < Integer > cbuf = Lists . newArrayList ( ) ; StringBuilder builder = new StringBuilder ( ) ; boolean result = true ; boolean seenChar = false ; while ( true ) { cbuf . add ( reader . next ( ) ) ; char ch = ( char ) reader . curChar ; if ( reader . curChar == - 1 ) { result = false ; break ; } else if ( WHITESPACE . matches ( ch ) ) { if ( seenChar ) { builder . append ( ch ) ; } } else { if ( builder . length ( ) == 0 ) { seenChar = true ; } builder . append ( ch ) ; int index = builder . length ( ) - 1 ; if ( ! ignoreCase && ( builder . charAt ( index ) == match . charAt ( index ) ) ) { result = false ; break ; } if ( ignoreCase && ( Ascii . toLowerCase ( builder . charAt ( index ) ) != Ascii . toLowerCase ( match . charAt ( index ) ) ) ) { result = false ; break ; } } if ( builder . length ( ) == match . length ( ) ) { if ( ! match . equalsIgnoreCase ( builder . toString ( ) ) ) { result = false ; } break ; } } if ( ! result || resetOnTrue ) { reader . unread ( cbuf , mark ) ; } return result ; }
Check if a forward scan will equal given match string