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