Package org.apache.avro.util
Class ByteBufferOutputStream
java.lang.Object
java.io.OutputStream
org.apache.avro.util.ByteBufferOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
Utility to collect data written to an
OutputStream in
ByteBuffers.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappend(List<ByteBuffer> lists) Append a list of ByteBuffers to this stream.Returns all data written and resets the stream to be empty.voidprepend(List<ByteBuffer> lists) Prepend a list of ByteBuffers to this stream.voidreset()voidwrite(byte[] b, int off, int len) voidwrite(int b) voidwrite(ByteBuffer buffer) voidwriteBuffer(ByteBuffer buffer) Add a buffer to the output without copying, if possible.Methods inherited from class java.io.OutputStream
close, flush, nullOutputStream, write
-
Field Details
-
BUFFER_SIZE
public static final int BUFFER_SIZE- See Also:
-
-
Constructor Details
-
ByteBufferOutputStream
public ByteBufferOutputStream()
-
-
Method Details
-
getBufferList
Returns all data written and resets the stream to be empty. -
prepend
Prepend a list of ByteBuffers to this stream. -
append
Append a list of ByteBuffers to this stream. -
reset
public void reset() -
write
-
write
public void write(int b) - Specified by:
writein classOutputStream
-
write
public void write(byte[] b, int off, int len) - Overrides:
writein classOutputStream
-
writeBuffer
Add a buffer to the output without copying, if possible.- Throws:
IOException
-