public static < T > T withWriter ( File file , @ ClosureParams ( value = SimpleType . class , options = "java.io.BufferedWriter" ) Closure < T > closure ) throws IOException { return IOGroovyMethods . withWriter ( newWriter ( file ) , closure ) ; }
Creates a new BufferedWriter for this file passes it to the closure and ensures the stream is flushed and closed after the closure returns .