public static void transformLine(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 {
    while ((line=br.readLine()) != null) {
      Object o=closure.call(line);
      if (o != null) {
        bw.write(o.toString());
        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);
  }
}

public static void transformLine ( 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 { while ( ( line = br . readLine ( ) ) != null ) { Object o = closure . call ( line ) ; if ( o != null ) { bw . write ( o . toString ( ) ) ; 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 ) ; } }
transforms the lines from a reader with a closure and write them to a writer . both reader and writer are closed after the operation .
