public static < T > T withWriter ( OutputStream stream , @ ClosureParams ( value = SimpleType . class , options = "java.io.Writer" ) Closure < T > closure ) throws IOException { return withWriter ( new OutputStreamWriter ( stream ) , closure ) ; }
Creates a writer from this stream passing it to the given closure . This method ensures the stream is closed after the closure returns .