Class DataOutputBuffer

  • All Implemented Interfaces:
    java.io.Closeable, java.io.DataOutput, java.io.Flushable, java.lang.AutoCloseable, DataOutputPlus
    Direct Known Subclasses:
    DataOutputBufferFixed, SafeMemoryWriter

    public class DataOutputBuffer
    extends BufferedDataOutputStreamPlus
    An implementation of the DataOutputStream interface using a FastByteArrayOutputStream and exposing its buffer so copies can be avoided. This class is completely thread unsafe.
    • Field Detail

      • scratchBuffer

        public static final io.netty.util.concurrent.FastThreadLocal<DataOutputBuffer> scratchBuffer
        Scratch buffers used mostly for serializing in memory. It's important to call #recycle() when finished to keep the memory overhead from being too large in the system.
    • Constructor Detail

      • DataOutputBuffer

        public DataOutputBuffer()
      • DataOutputBuffer

        public DataOutputBuffer​(int size)
      • DataOutputBuffer

        public DataOutputBuffer​(java.nio.ByteBuffer buffer)
    • Method Detail

      • expandToFit

        protected void expandToFit​(long count)
      • clear

        public void clear()
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class BufferedDataOutputStreamPlus
      • buffer

        public java.nio.ByteBuffer buffer()
      • buffer

        public java.nio.ByteBuffer buffer​(boolean duplicate)
      • getData

        public byte[] getData()
      • getLength

        public int getLength()
      • hasPosition

        public boolean hasPosition()
        Description copied from interface: DataOutputPlus
        If the implementation supports providing a position, this method returns true, otherwise false.
      • position

        public long position()
        Description copied from interface: DataOutputPlus
        Returns the current position of the underlying target like a file-pointer or the position withing a buffer. Not every implementation may support this functionality. Whether or not this functionality is supported can be checked via the DataOutputPlus.hasPosition().
      • asNewBuffer

        public java.nio.ByteBuffer asNewBuffer()
      • toByteArray

        public byte[] toByteArray()