Package: java.io

## [Java] Class Writer

- java.io.Writer

-     public class Writer
      extends Object

  GDK enhancements for Writer.

  displayName:
    Writer
  receiverFqcn:
    java.io.Writer

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public Writer` | `leftShift(Object value)` Overloads the leftShift operator for Writer to allow an object to be written using Groovy's default representation for the object.
    `` | `public PrintWriter` | `newPrintWriter()` Create a new PrintWriter for this Writer.
    `<T>` | `public T` | `withPrintWriter(Closure<T> closure)` Create a new PrintWriter for this Writer.
    `<T>` | `public T` | `withWriter(Closure<T> closure)` Allows this writer to be used within the closure, ensuring that it is flushed and closed before this method returns.
    `` | `public void` | `write(Writable writable)` A helper method so that dynamic dispatch of the writer.write(object) method will always use the more efficient Writable.writeTo(writer) mechanism if the object implements the Writable interface.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `addShutdownHook, any, any, asBoolean, asType, collect, collect, collect, dump, each, eachMatch, eachMatch, eachWithIndex, every, every, find, find, findAll, findAll, findIndexOf, findIndexOf, findIndexValues, findIndexValues, findLastIndexOf, findLastIndexOf, findResult, findResult, findResult, findResult, getAt, getMetaClass, getMetaPropertyValues, getProperties, grep, grep, hasProperty, identity, inject, inject, inspect, invokeMethod, is, isCase, isNotCase, iterator, metaClass, print, print, printf, printf, println, println, println, putAt, respondsTo, respondsTo, setMetaClass, sleep, sleep, split, sprintf, sprintf, stream, tap, toString, use, use, use, with, with, withCloseable, withCloseable, withMethodClosure, withStream, withStream, withTraits`

- - ### Method Detail

    - #### public Writer leftShift(Object value)

      Overloads the leftShift operator for Writer to allow an object to be written using Groovy's default representation for the object.

      throws:
        IOException if an I/O error occurs.
      Parameters:
        `value` - an Object whose default representation will be written to the Writer
      Returns:
        the writer on which this operation was invoked
      Since:
        1.0

    - #### public PrintWriter newPrintWriter()

      Create a new PrintWriter for this Writer.

      Returns:
        a PrintWriter
      Since:
        1.6.0

    - #### <T> public T withPrintWriter(Closure<T> closure)

      Create a new PrintWriter for this Writer. The writer is passed to the closure, and will be closed before this method returns.

      throws:
        IOException if an IOException occurs.
      Parameters:
        `closure` - the closure to invoke with the PrintWriter
      Returns:
        the value returned by the closure
      Since:
        1.6.0

    - #### <T> public T withWriter(Closure<T> closure)

      Allows this writer to be used within the closure, ensuring that it is flushed and closed before this method returns.

      throws:
        IOException if an IOException occurs.
      Parameters:
        `closure` - the closure that the writer is passed into
      Returns:
        the value returned by the closure
      Since:
        1.5.2

    - #### public void write(Writable writable)

      A helper method so that dynamic dispatch of the writer.write(object) method will always use the more efficient Writable.writeTo(writer) mechanism if the object implements the Writable interface.

      throws:
        IOException if an I/O error occurs.
      Parameters:
        `writable` - an object implementing the Writable interface
      Since:
        1.0