question: public static void filterLine ( Reader reader , Writer writer , @ ClosureParams ( value = SimpleType . class , options = "java.lang.String" ) Closure closure ) throws IOException { BufferedReader br = new BufferedReader ( reader ) ; BufferedWriter bw = new BufferedWriter ( writer ) ; String line ; try { BooleanClosureWrapper bcw = new BooleanClosureWrapper ( closure ) ; while ( ( line = br . readLine ( ) ) != null ) { if ( bcw . call ( line ) ) { bw . write ( line ) ; bw . newLine ( ) ; } } bw . flush ( ) ; Writer temp2 = writer ; writer = null ; temp2 . close ( ) ; Reader temp1 = reader ; reader = null ; temp1 . close ( ) ; } finally { closeWithWarning ( br ) ; closeWithWarning ( reader ) ; closeWithWarning ( bw ) ; closeWithWarning ( writer ) ; } }
target:  Filter the lines from a reader and write them on the writer, according to a closure which returns true if the line should be included. Both Reader and Writer are closed after the operation.