类 ByteBufferUtils

java.lang.Object
cn.wjybxx.base.io.ByteBufferUtils

public class ByteBufferUtils extends Object
作者:
wjybxx date - 2024/1/6
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    static void
    checkBuffer(byte[] buffer, int offset, int length)
    检查buffer参数
    static void
    checkBuffer(int bufferLength, int offset)
    检查buffer参数
    static void
    checkBuffer(int bufferLength, int offset, int length)
    检查buffer参数
    static byte
    getByte(byte[] buffer, int index)
     
    static short
    getInt16(byte[] buffer, int index)
    大端:从buffer中读取一个Int16
    static short
    getInt16LE(byte[] buffer, int index)
    小端:从buffer中读取一个Int16
    static int
    getInt32(byte[] buffer, int index)
    大端:从buffer中读取一个Int32
    static int
    getInt32LE(byte[] buffer, int index)
    小端:从buffer中读取一个Int32
    static long
    getInt64(byte[] buffer, int index)
    大端:从buffer中读取一个Int64
    static long
    getInt64LE(byte[] buffer, int index)
    小端:从buffer中读取一个Int64
    static long
    getUInt32(byte[] buffer, int index)
    大端:从buffer中读取一个Int32
    static long
    getUInt32LE(byte[] buffer, int index)
    小端:从buffer中读取一个Int32
    static long
    getUInt48(byte[] buffer, int index)
    大端:从buffer中读取一个UInt48
    static long
    getUInt48LE(byte[] buffer, int index)
    小端:从buffer中读取一个Int48
    static int
    getUnsignedByte(byte[] buffer, int index)
     
    static void
    position(Buffer byteBuffer, int newOffset)
    JDK9+的代码跑在JDK8上的兼容问题
    static void
    setByte(byte[] buffer, int index, byte value)
     
    static void
    setByte(byte[] buffer, int index, int value)
     
    static void
    setInt16(byte[] buffer, int index, short value)
    大端:向buffer中写入一个Int16
    static void
    setInt16LE(byte[] buffer, int index, short value)
    小端:向buffer中写入一个Int16
    static void
    setInt32(byte[] buffer, int index, int value)
    大端:向buffer中写入一个Int32
    static void
    setInt32LE(byte[] buffer, int index, int value)
    小端:向buffer中写入一个Int32
    static void
    setInt64(byte[] buffer, int index, long value)
    大端:向buffer中写入一个Int64
    static void
    setInt64LE(byte[] buffer, int index, long value)
    小端:向buffer中写入一个Int64
    static void
    setUInt32(byte[] buffer, int index, long value)
    大端:向buffer中写入一个Int32
    static void
    setUInt32LE(byte[] buffer, int index, long value)
    小端:向buffer中写入一个Int32
    static void
    setUInt48(byte[] buffer, int index, long value)
    大端:向buffer中写入一个UInt48
    static void
    setUInt48LE(byte[] buffer, int index, long value)
    小端:向buffer中写入一个Int48

    从类继承的方法 java.lang.Object

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

    • ByteBufferUtils

      public ByteBufferUtils()
  • 方法详细资料

    • checkBuffer

      public static void checkBuffer(byte[] buffer, int offset, int length)
      检查buffer参数
      参数:
      buffer - 要检查的数组
      offset - 数据的起始索引
      length - 数据的长度
    • checkBuffer

      public static void checkBuffer(int bufferLength, int offset, int length)
      检查buffer参数
      参数:
      bufferLength - buffer数组的长度
      offset - 数据的起始索引
      length - 数据的长度
    • checkBuffer

      public static void checkBuffer(int bufferLength, int offset)
      检查buffer参数
      参数:
      bufferLength - buffer数组的长度
      offset - 数据的起始索引
    • position

      public static void position(Buffer byteBuffer, int newOffset)
      JDK9+的代码跑在JDK8上的兼容问题
    • getByte

      public static byte getByte(byte[] buffer, int index)
    • setByte

      public static void setByte(byte[] buffer, int index, byte value)
    • getUnsignedByte

      public static int getUnsignedByte(byte[] buffer, int index)
    • setByte

      public static void setByte(byte[] buffer, int index, int value)
    • setInt16

      public static void setInt16(byte[] buffer, int index, short value)
      大端:向buffer中写入一个Int16
    • getInt16

      public static short getInt16(byte[] buffer, int index)
      大端:从buffer中读取一个Int16
    • setInt32

      public static void setInt32(byte[] buffer, int index, int value)
      大端:向buffer中写入一个Int32
    • getInt32

      public static int getInt32(byte[] buffer, int index)
      大端:从buffer中读取一个Int32
    • setUInt32

      public static void setUInt32(byte[] buffer, int index, long value)
      大端:向buffer中写入一个Int32
    • getUInt32

      public static long getUInt32(byte[] buffer, int index)
      大端:从buffer中读取一个Int32
    • setUInt48

      public static void setUInt48(byte[] buffer, int index, long value)
      大端:向buffer中写入一个UInt48
    • getUInt48

      public static long getUInt48(byte[] buffer, int index)
      大端:从buffer中读取一个UInt48
    • setInt64

      public static void setInt64(byte[] buffer, int index, long value)
      大端:向buffer中写入一个Int64
    • getInt64

      public static long getInt64(byte[] buffer, int index)
      大端:从buffer中读取一个Int64
    • setInt16LE

      public static void setInt16LE(byte[] buffer, int index, short value)
      小端:向buffer中写入一个Int16
    • getInt16LE

      public static short getInt16LE(byte[] buffer, int index)
      小端:从buffer中读取一个Int16
    • setInt32LE

      public static void setInt32LE(byte[] buffer, int index, int value)
      小端:向buffer中写入一个Int32
    • getInt32LE

      public static int getInt32LE(byte[] buffer, int index)
      小端:从buffer中读取一个Int32
    • setUInt32LE

      public static void setUInt32LE(byte[] buffer, int index, long value)
      小端:向buffer中写入一个Int32
    • getUInt32LE

      public static long getUInt32LE(byte[] buffer, int index)
      小端:从buffer中读取一个Int32
    • setUInt48LE

      public static void setUInt48LE(byte[] buffer, int index, long value)
      小端:向buffer中写入一个Int48
    • getUInt48LE

      public static long getUInt48LE(byte[] buffer, int index)
      小端:从buffer中读取一个Int48
    • setInt64LE

      public static void setInt64LE(byte[] buffer, int index, long value)
      小端:向buffer中写入一个Int64
    • getInt64LE

      public static long getInt64LE(byte[] buffer, int index)
      小端:从buffer中读取一个Int64