Package org.eclipse.net4j.buffer

# Class BufferOutputStream

java.lang.Object
java.io.OutputStream
org.eclipse.net4j.buffer.BufferOutputStream

All Implemented Interfaces:
  `Closeable`, `Flushable`, `AutoCloseable`

Direct Known Subclasses:
  `ChannelOutputStream`

public class BufferOutputStream extends OutputStream
An `output stream` that fragments the written byte sequence into fixed-sized `buffers` and passes them to configured `buffer handler`.

Author:
  Eike Stepper

## Field Summary

Fields
Modifier and Type
Field
Description
`static final boolean`
`DEFAULT_PROPAGATE_CLOSE`

## Constructor Summary

Constructors
Constructor
Description
`BufferOutputStream(IBufferHandler bufferHandler, short channelID)`
`BufferOutputStream(IBufferHandler bufferHandler, IBufferProvider bufferProvider, short channelID)`

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
`protected void`
`ensureBuffer()`
Ensures that this BufferOutputStream has a buffer.
`void`
`flush()`
Flushes the current buffer, it's handled over to the buffer handler.
`void`
`flushWithEOS()`
`void`
`flushWithEOS(boolean ccam)`
`Throwable`
`getError()`
`protected boolean`
`isPropagateClose()`
`void`
`setError(Throwable error)`
`String`
`toString()`
`void`
`write(byte[] b, int off, int len)`
`void`
`write(int b)`

### Methods inherited from class java.io.OutputStream

`nullOutputStream, write`

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### DEFAULT_PROPAGATE_CLOSE

public static final boolean DEFAULT_PROPAGATE_CLOSE

See Also:
  - Constant Field Values

## Constructor Details

### BufferOutputStream

public BufferOutputStream(IBufferHandler bufferHandler, IBufferProvider bufferProvider, short channelID)

### BufferOutputStream

public BufferOutputStream(IBufferHandler bufferHandler, short channelID)

## Method Details

### getError

public Throwable getError()

Since:
  2.0

### setError

public void setError(Throwable error)

Since:
  2.0

### write

public void write(int b) throws IOException

Specified by:
  `write` in class `OutputStream`
Throws:
  `IOException`

### write

public void write(byte[] b, int off, int len) throws IOException

Overrides:
  `write` in class `OutputStream`
Throws:
  `IOException`

### flush

public void flush() throws IOException
Flushes the current buffer, it's handled over to the buffer handler.

Specified by:
  `flush` in interface `Flushable`
Overrides:
  `flush` in class `OutputStream`
Throws:
  `IOException` - Signals that an I/O exception has occurred.
See Also:
  - `currentBuffer`
  - `IBufferHandler.handleBuffer(IBuffer)`

### flushWithEOS

public void flushWithEOS() throws IOException

Throws:
  `IOException`

### flushWithEOS

public void flushWithEOS(boolean ccam) throws IOException

Throws:
  `IOException`
Since:
  4.4

### close

public void close() throws IOException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Overrides:
  `close` in class `OutputStream`
Throws:
  `IOException`

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### ensureBuffer

protected void ensureBuffer() throws IOException
Ensures that this BufferOutputStream has a buffer. If the current buffer was flushed a new one is fetched from the buffer provider.

Throws:
  `IOException` - Signals that an I/O exception has occurred.
See Also:
  - `flush()`
  - `IBufferProvider.provideBuffer()`

### isPropagateClose

protected boolean isPropagateClose()