public String waitForStringInLog ( String regexp , long timeout , File outputFile ) { int waited = 0 ; final int waitIncrement = 500 ; log ( MessageFormat . format ( messages . getString ( "info.search.string" ) , regexp , outputFile . getAbsolutePath ( ) , timeout / 1000 ) ) ; try { while ( waited <= timeout ) { String string = findStringInFile ( regexp , outputFile ) ; if ( string == null ) { try { Thread . sleep ( waitIncrement ) ; } catch ( InterruptedException e ) { // Ignore and carry on } waited += waitIncrement ; } else { return string ; } } log ( MessageFormat . format ( messages . getString ( "error.serch.string.timeout" ) , regexp , outputFile . getAbsolutePath ( ) ) ) ; } catch ( Exception e ) { // I think we can assume if we can't read the file it doesn't // contain our string throw new BuildException ( e ) ; } return null ; }
Check for a number of strings in a potentially remote file