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
ConstructorsConstructorDescriptionReturns 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) voidclose()voidflush()voidInstall a new buffer for all future writes.voidsetSink(ByteBufferSink sink) Install a new sink for all future writes.voidwrite(byte[] ba) voidwrite(byte[] ba, int off, int len) voidwrite(int b) voidwrite(ByteBuffer b) voidwriteBoolean(boolean v) voidwriteByte(int v) voidwriteBytes(String s) voidwriteChar(int v) voidwriteChars(String s) voidwriteDouble(double d) voidwriteFloat(float f) voidwriteInt(int v) voidwriteLong(long v) voidwriteShort(int v) voidwriteUTF(CharSequence str) voidMethods 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Throws:
IOException
-
writeBoolean
- Specified by:
writeBooleanin interfaceDataOutput- Throws:
IOException
-
writeByte
- Specified by:
writeBytein interfaceDataOutput- Throws:
IOException
-
writeShort
- Specified by:
writeShortin interfaceDataOutput- Throws:
IOException
-
writeChar
- Specified by:
writeCharin interfaceDataOutput- Throws:
IOException
-
writeInt
- Specified by:
writeIntin interfaceDataOutput- Throws:
IOException
-
writeLong
- Specified by:
writeLongin interfaceDataOutput- Throws:
IOException
-
writeFloat
- Specified by:
writeFloatin interfaceDataOutput- Throws:
IOException
-
writeDouble
- Specified by:
writeDoublein interfaceDataOutput- Throws:
IOException
-
writeBytes
- Specified by:
writeBytesin interfaceDataOutput- Throws:
IOException
-
writeChars
- Specified by:
writeCharsin interfaceDataOutput- Throws:
IOException
-
writeUTF
- Specified by:
writeUTFin 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
-