public static < T > T withObjectOutputStream ( Path self , @ ClosureParams ( value = SimpleType . class , options = "java.io.ObjectOutputStream" ) Closure < T > closure ) throws IOException { return IOGroovyMethods . withStream ( newObjectOutputStream ( self ) , closure ) ; }
Create a new ObjectOutputStream for this path and then pass it to the closure . This method ensures the stream is closed after the closure returns .