Class ByteWriter


  • public class ByteWriter
    extends Object
    Write a byte array
    Author:
    osbornb
    • Constructor Detail

      • ByteWriter

        public ByteWriter()
        Constructor
      • ByteWriter

        public ByteWriter​(ByteOrder byteOrder)
        Constructor
        Parameters:
        byteOrder - byte order
    • Method Detail

      • close

        public void close()
        Close the byte writer
      • getOutputStream

        public ByteArrayOutputStream getOutputStream()
        Get the byte array output stream
        Returns:
        byte array output stream
      • getByteOrder

        public ByteOrder getByteOrder()
        Get the byte order
        Returns:
        byte order
      • setByteOrder

        public void setByteOrder​(ByteOrder byteOrder)
        Set the byte order
        Parameters:
        byteOrder - byte order
      • getBytes

        public byte[] getBytes()
        Get the written bytes
        Returns:
        written bytes
      • size

        public int size()
        Get the current size in bytes written
        Returns:
        bytes written
      • writeString

        public int writeString​(String value)
                        throws IOException
        Write a String
        Parameters:
        value - string value
        Returns:
        bytes written
        Throws:
        IOException - upon failure to write
      • writeByte

        public void writeByte​(byte value)
        Write a byte
        Parameters:
        value - byte
      • writeUnsignedByte

        public void writeUnsignedByte​(short value)
        Write an unsigned byte
        Parameters:
        value - unsigned byte as a short
      • writeBytes

        public void writeBytes​(byte[] value)
                        throws IOException
        Write the bytes
        Parameters:
        value - bytes
        Throws:
        IOException - upon failure to write
      • writeShort

        public void writeShort​(short value)
                        throws IOException
        Write a short
        Parameters:
        value - short
        Throws:
        IOException - upon failure to write
      • writeUnsignedShort

        public void writeUnsignedShort​(int value)
                                throws IOException
        Write an unsigned short
        Parameters:
        value - unsigned short as an int
        Throws:
        IOException - upon failure to write
      • writeInt

        public void writeInt​(int value)
                      throws IOException
        Write an integer
        Parameters:
        value - int
        Throws:
        IOException - upon failure to write
      • writeUnsignedInt

        public void writeUnsignedInt​(long value)
                              throws IOException
        Write an unsigned int
        Parameters:
        value - unsigned int as long
        Throws:
        IOException - upon failure to write
      • writeFloat

        public void writeFloat​(float value)
                        throws IOException
        Write a float
        Parameters:
        value - float
        Throws:
        IOException - upon failure to write
      • writeDouble

        public void writeDouble​(double value)
                         throws IOException
        Write a double
        Parameters:
        value - double
        Throws:
        IOException - upon failure to write