Class ByteBufferOutputStream

java.lang.Object
java.io.OutputStream
io.deephaven.io.streams.ByteBufferOutputStream
All Implemented Interfaces:
Closeable, DataOutput, Flushable, AutoCloseable

public class ByteBufferOutputStream extends OutputStream implements DataOutput
This is an OutputStream implementation which places the output into a java.nio.ByteBuffer. The constructor accepts an initial buffer and an instance of ByteBufferSink. When an output operation would cause the buffer to overflow, it is handed to the sink's acceptBuffer() method, which is expected to dispose of the existing contents and return a buffer in which writing can continue. Note that the stream contains no state other than the buffer itself, so the buffer and/or the sink can be switched at any time by calling setBuffer() or setSink().