public static void processReader ( BufferedReader br , ReaderProcessor processor ) throws ParserException { String line ; try { while ( ( line = br . readLine ( ) ) != null ) { processor . process ( line ) ; } } catch ( IOException e ) { throw new ParserException ( "Could not read from the given BufferedReader" ) ; } finally { close ( br ) ; } }
Takes in a reader and a processor reads every line from the given file and then invokes the processor . What you do with the lines is dependent on your processor .