public static < T > T withPrintWriter ( Path self , @ ClosureParams ( value = SimpleType . class , options = "java.io.PrintWriter" ) Closure < T > closure ) throws IOException { return IOGroovyMethods . withWriter ( newPrintWriter ( self ) , closure ) ; }
Create a new PrintWriter for this file which is then passed it into the given closure . This method ensures its the writer is closed after the closure returns .