Class GrowableByteArrayDataOutput


  • public final class GrowableByteArrayDataOutput
    extends DataOutput
    A DataOutput that can be used to build a byte[].
    • Field Detail

      • MIN_UTF8_SIZE_TO_ENABLE_DOUBLE_PASS_ENCODING

        static final int MIN_UTF8_SIZE_TO_ENABLE_DOUBLE_PASS_ENCODING
        Minimum utf8 byte size of a string over which double pass over string is to save memory during encode
        See Also:
        Constant Field Values
      • bytes

        private byte[] bytes
        The bytes
      • length

        private int length
        The length
      • scratchBytes

        private byte[] scratchBytes
    • Constructor Detail

      • GrowableByteArrayDataOutput

        public GrowableByteArrayDataOutput​(int cp)
        Create a GrowableByteArrayDataOutput with the given initial capacity.
    • Method Detail

      • writeByte

        public void writeByte​(byte b)
        Description copied from class: DataOutput
        Writes a single byte.

        The most primitive data type is an eight-bit byte. Files are accessed as sequences of bytes. All other data types are defined as sequences of bytes, so file formats are byte-order independent.

        Specified by:
        writeByte in class DataOutput
        See Also:
        DataInput.readByte()
      • writeBytes

        public void writeBytes​(byte[] b,
                               int off,
                               int len)
        Description copied from class: DataOutput
        Writes an array of bytes.
        Specified by:
        writeBytes in class DataOutput
        Parameters:
        b - the bytes to write
        off - the offset in the byte array
        len - the number of bytes to write
        See Also:
        DataInput.readBytes(byte[],int,int)
      • writeString

        public void writeString​(java.lang.String string)
                         throws java.io.IOException
        Description copied from class: DataOutput
        Writes a string.

        Writes strings as UTF-8 encoded bytes. First the length, in bytes, is written as a VInt, followed by the bytes.

        Overrides:
        writeString in class DataOutput
        Throws:
        java.io.IOException
        See Also:
        DataInput.readString()
      • getBytes

        public byte[] getBytes()
      • getPosition

        public int getPosition()
      • reset

        public void reset()