Package 

Class MemoryPooledByteBufferOutputStream

  • All Implemented Interfaces:
    java.io.Closeable , java.io.Flushable , java.lang.AutoCloseable

    @NotThreadSafe() 
    public final class MemoryPooledByteBufferOutputStream
    extends PooledByteBufferOutputStream
                        

    An implementation of PooledByteBufferOutputStream that produces a MemoryPooledByteBuffer

    • 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.

      • size

         Integer size()

        Returns the total number of bytes written to this stream so far.

      • 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 count bytes from the byte array buffer starting at position offset to this stream. The underlying stream MUST be valid

        Parameters:
        buffer - the source buffer to read from
        offset - the start position in buffer from where to get bytes.
        count - the number of bytes from buffer to 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.

      • realloc

         final Unit realloc(Integer newLength)

        Reallocate the local buffer to hold the new length specified. Also copy over existing data to this new buffer

        Parameters:
        newLength - new length of buffer