Package: java.io

## Class OutputStream

- - ### Methods Summary

    Methods
    Return type | Name and parameters
    --- | ---
    `OutputStream` | `leftShift(byte[] value)` Overloads the leftShift operator to provide an append mechanism to add bytes to a stream.
    `OutputStream` | `leftShift(InputStream in)` Pipe an InputStream into an OutputStream for efficient stream copying.
    `Writer` | `leftShift(Object value)` Overloads the leftShift operator to provide an append mechanism to add values to a stream.
    `ObjectOutputStream` | `newObjectOutputStream()` Create an object output stream for this output stream.
    `PrintWriter` | `newPrintWriter()` Create a new PrintWriter for this OutputStream.
    `Writer` | `newWriter()` Creates a writer for this stream.
    `Writer` | `newWriter(String charset)` Creates a writer for this stream using the given charset.
    `void` | `setBytes(byte[] bytes)` Write the byte[] to the output stream.
    `Object` | `withObjectOutputStream(Closure closure)` Create a new ObjectOutputStream for this output stream and then pass it to the closure.
    `Object` | `withPrintWriter(Closure closure)` Create a new PrintWriter for this OutputStream.
    `Object` | `withStream(Closure closure)` Passes this OutputStream to the closure, ensuring that the stream is closed after the closure returns, regardless of errors.
    `Object` | `withWriter(Closure closure)` Creates a writer from this stream, passing it to the given closure.
    `Object` | `withWriter(String charset, Closure closure)` Creates a writer from this stream, passing it to the given closure.

  - #### Methods inherited from class java.lang.Object

    `addShutdownHook`, `any`, `any`, `asBoolean`, `asType`, `collect`, `collect`, `collect`, `contains`, `count`, `dump`, `each`, `eachWithIndex`, `equals`, `every`, `every`, `find`, `find`, `findAll`, `findAll`, `findIndexOf`, `findIndexOf`, `findIndexValues`, `findIndexValues`, `findLastIndexOf`, `findLastIndexOf`, `findResult`, `findResult`, `flatten`, `getAt`, `getMetaClass`, `getMetaPropertyValues`, `getProperties`, `grep`, `grep`, `groupBy`, `groupBy`, `hasProperty`, `identity`, `inject`, `inject`, `inspect`, `invokeMethod`, `is`, `isCase`, `iterator`, `join`, `metaClass`, `print`, `print`, `printf`, `printf`, `println`, `println`, `println`, `putAt`, `respondsTo`, `respondsTo`, `setMetaClass`, `size`, `split`, `sprintf`, `sprintf`, `sum`, `sum`, `sum`, `sum`, `toArrayString`, `toSpreadMap`, `toString`, `use`, `use`, `use`, `with`, `withTraits`

  - #### Methods inherited from interface java.io.Closeable

    `withCloseable`

- - ### Methods Detail

    - #### public OutputStream leftShift(byte[] value)

      Overloads the leftShift operator to provide an append mechanism to add bytes to a stream.

      Parameters:
        `value` - a value to append
      Returns:
        an OutputStream
      Since:
        1.0

    - #### public OutputStream leftShift(InputStream in)

      Pipe an InputStream into an OutputStream for efficient stream copying.

      Parameters:
        `in` - stream to read from
      Returns:
        the outputstream itself
      Since:
        1.0

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

      Overloads the leftShift operator to provide an append mechanism to add values to a stream.

      Parameters:
        `value` - a value to append
      Returns:
        a Writer
      Since:
        1.0

    - #### public ObjectOutputStream newObjectOutputStream()

      Create an object output stream for this output stream.

      Returns:
        an object output stream
      Since:
        1.5.0

    - #### public PrintWriter newPrintWriter()

      Create a new PrintWriter for this OutputStream.

      Returns:
        a PrintWriter
      Since:
        2.2.0

    - #### public Writer newWriter()

      Creates a writer for this stream.

      Returns:
        the newly created Writer
      Since:
        2.2.0

    - #### public Writer newWriter(String charset)

      Creates a writer for this stream using the given charset.

      Parameters:
        `charset` - the charset used
      Returns:
        the newly created Writer
      Since:
        2.2.0

    - #### public void setBytes(byte[] bytes)

      Write the byte[] to the output stream. The stream is closed before this method returns.

      Parameters:
        `bytes` - the byte[] to write to the output stream
      Since:
        1.7.1

    - #### public Object withObjectOutputStream(Closure 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.

      Parameters:
        `closure` - a closure
      Returns:
        the value returned by the closure
      Since:
        1.5.0
      See Also:
        OutputStream#withStream(groovy.lang.Closure)

    - #### public Object withPrintWriter(Closure closure)

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

      Parameters:
        `closure` - the closure to invoke with the PrintWriter
      Returns:
        the value returned by the closure
      Since:
        2.2.0

    - #### public Object withStream(Closure closure)

      Passes this OutputStream to the closure, ensuring that the stream is closed after the closure returns, regardless of errors.

      Parameters:
        `closure` - the closure that the stream is passed into
      Returns:
        the value returned by the closure
      Since:
        1.5.2

    - #### public Object withWriter(Closure closure)

      Creates a writer from this stream, passing it to the given closure. This method ensures the stream is closed after the closure returns.

      Parameters:
        `closure` - the closure that the writer is passed into
      Returns:
        the value returned by the closure
      Since:
        1.5.2
      See Also:
        Writer#withWriter(groovy.lang.Closure)

    - #### public Object withWriter(String charset, Closure closure)

      Creates a writer from this stream, passing it to the given closure. This method ensures the stream is closed after the closure returns.

      Parameters:
        `charset` - the charset used
        `closure` - the closure that the writer is passed into
      Returns:
        the value returned by the closure
      Since:
        1.5.2
      See Also:
        Writer#withWriter(groovy.lang.Closure)