类 ByteReader


  • public class ByteReader
    extends java.lang.Object
    Read through a byte array
    作者:
    osbornb
    • 构造器概要

      构造器 
      构造器 说明
      ByteReader​(byte[] bytes)
      Constructor
      ByteReader​(byte[] bytes, java.nio.ByteOrder byteOrder)
      Constructor
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      int byteLength()
      Get the byte length
      java.nio.ByteOrder getByteOrder()
      Get the byte order
      int getNextByte()
      Get the next byte to be read
      boolean hasByte()
      Check if there is at least one more byte left to read
      boolean hasByte​(int offset)
      Check if there is at least one more byte left to read
      boolean hasBytes​(int count)
      Check if there are the provided number of bytes left to read
      boolean hasBytes​(int offset, int count)
      Check if there are the provided number of bytes left to read
      byte readByte()
      Read a byte
      byte readByte​(int offset)
      Read a byte
      byte[] readBytes​(int num)
      Read a number of bytes
      byte[] readBytes​(int offset, int num)
      Read a number of bytes
      double readDouble()
      Read a double
      double readDouble​(int offset)
      Read a double
      float readFloat()
      Read a float
      float readFloat​(int offset)
      Read a float
      int readInt()
      Read an integer
      int readInt​(int offset)
      Read an integer
      short readShort()
      Read a short
      short readShort​(int offset)
      Read a short
      java.lang.String readString​(int num)
      Read a String from the provided number of bytes
      java.lang.String readString​(int offset, int num)
      Read a String from the provided number of bytes
      short readUnsignedByte()
      Read an unsigned byte
      short readUnsignedByte​(int offset)
      Read an unsigned byte
      long readUnsignedInt()
      Read an unsigned int
      long readUnsignedInt​(int offset)
      Read an unsigned int
      int readUnsignedShort()
      Read an unsigned short
      int readUnsignedShort​(int offset)
      Read an unsigned short
      void setByteOrder​(java.nio.ByteOrder byteOrder)
      Set the byte order
      void setNextByte​(int nextByte)
      Set the next byte to be read
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • ByteReader

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

        public ByteReader​(byte[] bytes,
                          java.nio.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 java.nio.ByteOrder getByteOrder()
        Get the byte order
        返回:
        byte order
      • setByteOrder

        public void setByteOrder​(java.nio.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
      • readString

        public java.lang.String readString​(int num)
                                    throws java.io.UnsupportedEncodingException
        Read a String from the provided number of bytes
        参数:
        num - number of bytes
        返回:
        String
        抛出:
        java.io.UnsupportedEncodingException
      • readString

        public java.lang.String readString​(int offset,
                                           int num)
                                    throws java.io.UnsupportedEncodingException
        Read a String from the provided number of bytes
        参数:
        offset - byte offset
        num - number of bytes
        返回:
        String
        抛出:
        java.io.UnsupportedEncodingException
      • 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