Class ByteReader


  • public class ByteReader
    extends Object
    Read through a byte array
    Author:
    osbornb
    • Field Detail

      • DEFAULT_BYTE_ORDER

        public static final ByteOrder DEFAULT_BYTE_ORDER
        Default read byte order
        Since:
        2.0.3
    • Constructor Detail

      • ByteReader

        public ByteReader​(byte[] bytes)
        Constructor
        Parameters:
        bytes - bytes
      • ByteReader

        public ByteReader​(InputStream inputStream)
        Constructor
        Parameters:
        inputStream - input stream
        Since:
        2.0.3
      • ByteReader

        public ByteReader​(byte[] bytes,
                          ByteOrder byteOrder)
        Constructor
        Parameters:
        bytes - bytes
        byteOrder - byte order
        Since:
        2.0.3
      • ByteReader

        public ByteReader​(InputStream inputStream,
                          ByteOrder byteOrder)
        Constructor
        Parameters:
        inputStream - input stream
        byteOrder - byte order
        Since:
        2.0.3
    • Method Detail

      • getBytes

        public byte[] getBytes()
        Get the bytes
        Returns:
        bytes
        Since:
        2.0.3
      • getInputStream

        public InputStream getInputStream()
        Get the output stream
        Returns:
        output stream
        Since:
        2.0.3
      • close

        public void close()
        Close the byte reader
        Since:
        2.0.3
      • getNextByte

        public int getNextByte()
        Get the next byte to be read
        Returns:
        next byte to be read
      • 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
      • readString

        public String readString​(int num)
                          throws IOException
        Read a String from the provided number of bytes
        Parameters:
        num - number of bytes
        Returns:
        String
        Throws:
        IOException - upon error
      • readBytes

        public byte[] readBytes​(int num)
                         throws IOException
        Read the number of bytes
        Parameters:
        num - number of bytes
        Returns:
        bytes
        Throws:
        IOException - upon error
      • readByte

        public byte readByte()
                      throws IOException
        Read a byte
        Returns:
        byte
        Throws:
        IOException - upon error
      • readInt

        public int readInt()
                    throws IOException
        Read an integer
        Returns:
        integer
        Throws:
        IOException - upon error
      • readUnsignedInt

        public long readUnsignedInt()
                             throws IOException
        Read an unsigned integer
        Returns:
        unsigned integer
        Throws:
        IOException - upon error
      • readDouble

        public double readDouble()
                          throws IOException
        Read a double
        Returns:
        double
        Throws:
        IOException - upon error