public static <T>T withWriter(Writer writer,@ClosureParams(FirstParam.class) Closure<T> closure) throws IOException {
  try {
    T result=closure.call(writer);
    try {
      writer.flush();
    }
 catch (    IOException e) {
    }
    Writer temp=writer;
    writer=null;
    temp.close();
    return result;
  }
  finally {
    closeWithWarning(writer);
  }
}

public static < T > T withWriter ( Writer writer , @ ClosureParams ( FirstParam . class ) Closure < T > closure ) throws IOException { try { T result = closure . call ( writer ) ; try { writer . flush ( ) ; } catch ( IOException e ) { } Writer temp = writer ; writer = null ; temp . close ( ) ; return result ; } finally { closeWithWarning ( writer ) ; } }
allows this writer to be used within the closure , ensuring that it is flushed and closed before this method returns .
