public static TailResults tailLog ( String uri , TailResults previousResults , Function < String , Void > lineProcessor ) throws IOException { URL logURL = new URL ( uri ) ; try ( InputStream inputStream = logURL . openStream ( ) ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; int count = 0 ; String lastLine = null ; while ( true ) { String line = reader . readLine ( ) ; if ( line == null ) break ; lastLine = line ; if ( previousResults . isNewLine ( line , count ) ) { lineProcessor . apply ( line ) ; } count ++ ; } return new TailResults ( count , lastLine ) ; } }
Tails the log of the given URL such as a build log processing all new lines since the last results