Groovy JDK

## java.io
Class OutputStream

Method Summary
`Writer` | `leftShift(Object value)` Overloads the leftShift operator to provide an append mechanism to add values to a stream.
`OutputStream` | `leftShift(InputStream in)` Pipe an InputStream into an OutputStream for efficient stream copying.
`OutputStream` | `leftShift(byte[] value)` Overloads the leftShift operator to provide an append mechanism to add bytes to a stream.
`ObjectOutputStream` | `newObjectOutputStream()` Create an object output stream for this output stream.
`Object` | `withObjectOutputStream(Closure closure)` Create a new ObjectOutputStream for this output stream and then pass it to the closure.
`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.

Method Detail

### leftShift

    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

### leftShift

    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

### leftShift

    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

### newObjectOutputStream

    public ObjectOutputStream newObjectOutputStream()

  Create an object output stream for this output stream.

Returns:
  an object output stream

Since:
  1.5.0

### withObjectOutputStream

    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:
  #withStream(OutputStream,Closure).

### withStream

    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

### withWriter

    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:
  #withWriter(Writer,Closure).

### withWriter

    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:
  #withWriter(Writer,Closure).

Groovy JDK