public String findWithinHorizon ( Pattern pattern , int horizon ) { ensureOpen ( ) ; if ( pattern == null ) throw new NullPointerException ( ) ; if ( horizon < 0 ) throw new IllegalArgumentException ( "horizon < 0" ) ; clearCaches ( ) ; // Search for the pattern while ( true ) { String token = findPatternInBuffer ( pattern , horizon ) ; if ( token != null ) { matchValid = true ; return token ; } if ( needInput ) readInput ( ) ; else break ; // up to end of input } return null ; }
Attempts to find the next occurrence of the specified pattern .