-
- All Implemented Interfaces:
-
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
@NotThreadSafe() public final class MemoryPooledByteBufferOutputStream extends PooledByteBufferOutputStreamAn implementation of PooledByteBufferOutputStream that produces a MemoryPooledByteBuffer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classMemoryPooledByteBufferOutputStream.InvalidStreamExceptionAn exception indicating that this stream is no longer valid
-
Constructor Summary
Constructors Constructor Description MemoryPooledByteBufferOutputStream(MemoryChunkPool pool, Integer initialCapacity)MemoryPooledByteBufferOutputStream(MemoryChunkPool pool)
-
Method Summary
Modifier and Type Method Description MemoryPooledByteBuffertoByteBuffer()Gets a PooledByteBuffer from the current contents. Integersize()Returns the total number of bytes written to this stream so far. Unitwrite(Integer oneByte)Write one byte to the underlying stream. Unitwrite(ByteArray buffer, Integer offset, Integer count)Writes countbytes from the byte arraybufferstarting at positionoffsetto this stream.Unitclose()Closes the stream. final Unitrealloc(Integer newLength)Reallocate the local buffer to hold the new length specified. -
-
Constructor Detail
-
MemoryPooledByteBufferOutputStream
MemoryPooledByteBufferOutputStream(MemoryChunkPool pool, Integer initialCapacity)
-
MemoryPooledByteBufferOutputStream
MemoryPooledByteBufferOutputStream(MemoryChunkPool pool)
-
-
Method Detail
-
toByteBuffer
MemoryPooledByteBuffer toByteBuffer()
Gets a PooledByteBuffer from the current contents. If the stream has already been closed, then an InvalidStreamException is thrown.
-
write
Unit write(Integer oneByte)
Write one byte to the underlying stream. The underlying stream MUST be valid
- Parameters:
oneByte- the one byte to write
-
write
Unit write(ByteArray buffer, Integer offset, Integer count)
Writes
countbytes from the byte arraybufferstarting at positionoffsetto this stream. The underlying stream MUST be valid- Parameters:
buffer- the source buffer to read fromoffset- the start position inbufferfrom where to get bytes.count- the number of bytes frombufferto write to this stream.
-
close
Unit close()
Closes the stream. Owned resources are released back to the pool. It is not allowed to call toByteBuffer after call to this method.
-
-
-
-