Class BinaryOutputStream

    • Constructor Detail

      • BinaryOutputStream

        public BinaryOutputStream​(OutputStream out)
    • Method Detail

      • writeByte

        public void writeByte​(byte integer)
                       throws IOException
        Write a signed byte to the output stream.
        Parameters:
        integer - The number to writeBinary.
        Throws:
        IOException - if unable to write to stream.
      • writeShort

        public abstract void writeShort​(short integer)
                                 throws IOException
        Write a signed short to the output stream.
        Parameters:
        integer - The number to writeBinary.
        Throws:
        IOException - if unable to write to stream.
      • writeInt

        public abstract void writeInt​(int integer)
                               throws IOException
        Write a signed int to the output stream.
        Parameters:
        integer - The number to writeBinary.
        Throws:
        IOException - if unable to write to stream.
      • writeLong

        public abstract void writeLong​(long integer)
                                throws IOException
        Write a signed long to the output stream.
        Parameters:
        integer - The number to writeBinary.
        Throws:
        IOException - if unable to write to stream.
      • writeFloat

        public void writeFloat​(float value)
                        throws IOException
        Write a float value to stream.
        Parameters:
        value - The double value to writeBinary.
        Throws:
        IOException - if unable to write to stream.
      • writeDouble

        public void writeDouble​(double value)
                         throws IOException
        Write a double value to stream.
        Parameters:
        value - The double value to writeBinary.
        Throws:
        IOException - if unable to write to stream.
      • writeUInt8

        public void writeUInt8​(int number)
                        throws IOException
        Parameters:
        number - Unsigned byte to writeBinary.
        Throws:
        IOException - if unable to write to stream.
      • writeUInt16

        public abstract void writeUInt16​(int number)
                                  throws IOException
        Parameters:
        number - Unsigned short to writeBinary.
        Throws:
        IOException - if unable to write to stream.
      • writeUInt24

        public abstract void writeUInt24​(int number)
                                  throws IOException
        Parameters:
        number - Unsigned short to writeBinary.
        Throws:
        IOException - if unable to write to stream.
      • writeUInt32

        public abstract void writeUInt32​(int number)
                                  throws IOException
        Parameters:
        number - Unsigned short to writeBinary.
        Throws:
        IOException - if unable to write to stream.
      • writeUnsigned

        public void writeUnsigned​(int number,
                                  int bytes)
                           throws IOException
        Parameters:
        number - Unsigned integer to writeBinary.
        bytes - Number of bytes to writeBinary.
        Throws:
        IOException - if unable to write to stream.
      • writeSigned

        public void writeSigned​(int number,
                                int bytes)
                         throws IOException
        Parameters:
        number - Signed integer to writeBinary.
        bytes - Number of bytes to writeBinary.
        Throws:
        IOException - if unable to write to stream.
      • writeSigned

        public void writeSigned​(long number,
                                int bytes)
                         throws IOException
        Parameters:
        number - Signed integer to writeBinary.
        bytes - Number of bytes to writeBinary.
        Throws:
        IOException - if unable to write to stream.
      • writeZigzag

        public int writeZigzag​(int number)
                        throws IOException
        Write a long number as zigzag encoded to the stream. The least significant bit becomes the sign, and the actual value is mad absolute and shifted one bit. This makes it maximum compressed both when positive and negative.
        Parameters:
        number - The number to writeBinary.
        Returns:
        Number of bytes written.
        Throws:
        IOException - if unable to write to stream.
      • writeZigzag

        public int writeZigzag​(long number)
                        throws IOException
        Write a long number as zigzag encoded to the stream. The least significant bit becomes the sign, and the actual value is mad absolute and shifted one bit. This makes it maximum compressed both when positive and negative.
        Parameters:
        number - The number to writeBinary.
        Returns:
        Number of bytes written.
        Throws:
        IOException - if unable to write to stream.
      • writeBase128

        public int writeBase128​(int i)
                         throws IOException
        Write a signed number as varint (integer with variable number of bytes, determined as part of the bytes themselves.
        Parameters:
        i - The number to writeBinary.
        Returns:
        The number of bytes written.
        Throws:
        IOException - if unable to write to stream.
      • writeBase128

        public int writeBase128​(long i)
                         throws IOException
        Write a signed number as base 128 (integer with variable number of bytes, determined as part of the bytes themselves.
        Parameters:
        i - The number to writeBinary.
        Returns:
        The number of bytes written.
        Throws:
        IOException - if unable to write to stream.