Package io.deephaven.io.streams
Class ByteBufferOutputStream
java.lang.Object
java.io.OutputStream
io.deephaven.io.streams.ByteBufferOutputStream
- All Implemented Interfaces:
Closeable
,DataOutput
,Flushable
,AutoCloseable
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().
-
Constructor Summary
ConstructorDescriptionReturns a new ByteBufferOutputStream with the specified initial buffer and sink. -
Method Summary
Modifier and TypeMethodDescriptionappendByte
(byte n) appendBytes
(CharSequence s, int position, int len) appendChars
(CharSequence s, int position, int len) appendDouble
(double p) appendInt
(int n) appendLong
(long n) appendShort
(short n) void
close()
void
flush()
void
Install a new buffer for all future writes.void
setSink
(ByteBufferSink sink) Install a new sink for all future writes.void
write
(byte[] ba) void
write
(byte[] ba, int off, int len) void
write
(int b) void
write
(ByteBuffer b) void
writeBoolean
(boolean v) void
writeByte
(int v) void
writeBytes
(String s) void
writeChar
(int v) void
writeChars
(String s) void
writeDouble
(double d) void
writeFloat
(float f) void
writeInt
(int v) void
writeLong
(long v) void
writeShort
(int v) void
writeUTF
(CharSequence str) void
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
ByteBufferOutputStream
Returns a new ByteBufferOutputStream with the specified initial buffer and sink.- Parameters:
b
- The initial buffersink
- The sink that should be used to accept full buffers
-
-
Method Details
-
setBuffer
Install a new buffer for all future writes. -
setSink
Install a new sink for all future writes. -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
- Throws:
IOException
-
writeBoolean
- Specified by:
writeBoolean
in interfaceDataOutput
- Throws:
IOException
-
writeByte
- Specified by:
writeByte
in interfaceDataOutput
- Throws:
IOException
-
writeShort
- Specified by:
writeShort
in interfaceDataOutput
- Throws:
IOException
-
writeChar
- Specified by:
writeChar
in interfaceDataOutput
- Throws:
IOException
-
writeInt
- Specified by:
writeInt
in interfaceDataOutput
- Throws:
IOException
-
writeLong
- Specified by:
writeLong
in interfaceDataOutput
- Throws:
IOException
-
writeFloat
- Specified by:
writeFloat
in interfaceDataOutput
- Throws:
IOException
-
writeDouble
- Specified by:
writeDouble
in interfaceDataOutput
- Throws:
IOException
-
writeBytes
- Specified by:
writeBytes
in interfaceDataOutput
- Throws:
IOException
-
writeChars
- Specified by:
writeChars
in interfaceDataOutput
- Throws:
IOException
-
writeUTF
- Specified by:
writeUTF
in interfaceDataOutput
- Throws:
IOException
-
writeUTF
- Throws:
IOException
-
appendByteBuffer
- Throws:
IOException
-
appendByte
- Throws:
IOException
-
appendShort
- Throws:
IOException
-
appendInt
- Throws:
IOException
-
appendLong
- Throws:
IOException
-
appendDouble
- Throws:
IOException
-
appendChars
- Throws:
IOException
-
appendChars
- Throws:
IOException
-
appendBytes
- Throws:
IOException
-
appendBytes
- Throws:
IOException
-
getBuffer
-