code: 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);
      }
docs: Creates a writer from this stream, passing it to the given closure.
  This method ensures the stream is closed after the closure returns.
  
  @param stream  the stream which is used and then closed
  @param closure the closure that the writer is passed into
  @return the value returned by the closure
  @throws IOException if an IOException occurs.
  @see #withWriter(java.io.Writer, groovy.lang.Closure)
  @since 1.5.2