类 ByteReader


  • public class ByteReader
    extends Object
    Read through a byte array
    作者:
    osbornb
    • 构造器详细资料

      • ByteReader

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

        public ByteReader​(byte[] bytes,
                          ByteOrder byteOrder)
        Constructor
        参数:
        bytes - bytes
        byteOrder - byte order
    • 方法详细资料

      • getNextByte

        public int getNextByte()
        Get the next byte to be read
        返回:
        next byte to be read
      • setNextByte

        public void setNextByte​(int nextByte)
        Set the next byte to be read
        参数:
        nextByte - next byte
      • getByteOrder

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

        public void setByteOrder​(ByteOrder byteOrder)
        Set the byte order
        参数:
        byteOrder - byte order
      • hasByte

        public boolean hasByte()
        Check if there is at least one more byte left to read
        返回:
        true more bytes left to read
      • hasByte

        public boolean hasByte​(int offset)
        Check if there is at least one more byte left to read
        参数:
        offset - byte offset
        返回:
        true more bytes left to read
      • hasBytes

        public boolean hasBytes​(int count)
        Check if there are the provided number of bytes left to read
        参数:
        count - number of bytes
        返回:
        true if has at least the number of bytes left
      • hasBytes

        public boolean hasBytes​(int offset,
                                int count)
        Check if there are the provided number of bytes left to read
        参数:
        offset - byte offset
        count - number of bytes
        返回:
        true if has at least the number of bytes left
      • readByte

        public byte readByte()
        Read a byte
        返回:
        byte
      • readByte

        public byte readByte​(int offset)
        Read a byte
        参数:
        offset - byte offset
        返回:
        byte
      • readUnsignedByte

        public short readUnsignedByte()
        Read an unsigned byte
        返回:
        unsigned byte as short
      • readUnsignedByte

        public short readUnsignedByte​(int offset)
        Read an unsigned byte
        参数:
        offset - byte offset
        返回:
        unsigned byte as short
      • readBytes

        public byte[] readBytes​(int num)
        Read a number of bytes
        参数:
        num - number of bytes
        返回:
        bytes
      • readBytes

        public byte[] readBytes​(int offset,
                                int num)
        Read a number of bytes
        参数:
        offset - byte offset
        num - number of bytes
        返回:
        bytes
      • readShort

        public short readShort()
        Read a short
        返回:
        short
      • readShort

        public short readShort​(int offset)
        Read a short
        参数:
        offset - byte offset
        返回:
        short
      • readUnsignedShort

        public int readUnsignedShort()
        Read an unsigned short
        返回:
        unsigned short as int
      • readUnsignedShort

        public int readUnsignedShort​(int offset)
        Read an unsigned short
        参数:
        offset - byte offset
        返回:
        unsigned short as int
      • readInt

        public int readInt()
        Read an integer
        返回:
        integer
      • readInt

        public int readInt​(int offset)
        Read an integer
        参数:
        offset - byte offset
        返回:
        integer
      • readUnsignedInt

        public long readUnsignedInt()
        Read an unsigned int
        返回:
        unsigned int as long
      • readUnsignedInt

        public long readUnsignedInt​(int offset)
        Read an unsigned int
        参数:
        offset - byte offset
        返回:
        unsigned int as long
      • readFloat

        public float readFloat()
        Read a float
        返回:
        float
      • readFloat

        public float readFloat​(int offset)
        Read a float
        参数:
        offset - byte offset
        返回:
        float
      • readDouble

        public double readDouble()
        Read a double
        返回:
        double
      • readDouble

        public double readDouble​(int offset)
        Read a double
        参数:
        offset - byte offset
        返回:
        double
      • byteLength

        public int byteLength()
        Get the byte length
        返回:
        byte length