类 Bytes

java.lang.Object
net.apexes.commons.lang.Bytes

public final class Bytes extends Object
作者:
HeDYn
  • 方法详细资料

    • bytesToInt

      public static int bytesToInt(byte[] bytes)
      byte数组构成int类型值 与intToBytes(int)方法互逆,即 value == byteToInt(intToByte(value)) 恒为true
      参数:
      bytes - 需要转换成int型值的byte数组
      返回:
      返回指定字节数组构成的int值
    • intToBytes

      public static byte[] intToBytes(int value)
      int型值转换成byte数组 与bytesToInt(byte[])方法互逆,即 value == byteToInt(intToByte(value)) 恒为true
      参数:
      value - 值
      返回:
      返回转换后的byte数组
    • bytesToLong

      public static long bytesToLong(byte[] bytes)
      byte数组构成long类型值。 与longToBytes(long)方法互逆,即 value == bytesToLong(longToBytes(value)) 恒为true
      参数:
      bytes - 需要转换成long型值的byte数组
      返回:
      返回指定字节数组构成的long值
    • longToBytes

      public static byte[] longToBytes(long value)
      long型值转换成byte数组。 与bytesToLong(byte[])方法互逆,即 value == bytesToLong(bytesToLong(value)) 恒为true
      参数:
      value -
      返回:
    • bytesToShort

      public static short bytesToShort(byte[] bytes)
      byte数组构成short类型值
      参数:
      bytes -
      返回:
      返回指定字节数组构成的short值
    • shortToBytes

      public static byte[] shortToBytes(short value)
      short型转byte数组
      参数:
      value -
      返回:
      返回转换后的byte数组
    • fromHex

      public static byte[] fromHex(String hex)
      将表示十六进制值的字符串转换为byte数组 与toHex(byte[])方法互逆
      参数:
      hex - 需要转换的十六进形式字符串
      返回:
      转换后的byte数组
    • toHex

      public static String toHex(byte[] bytes)
      以十六进制字符串形式显示byte数组 与fromHex(String)方法互逆
      参数:
      bytes - 字符数组
      返回:
      返回字节数组的十六进制形式
    • toHex

      public static String toHex(int value)
    • toHex

      public static String toHex(long value)
    • toHex

      public static String toHex(short value)
    • toHex

      public static String toHex(byte value)
    • hexFormat

      public static String hexFormat(byte[] bytes)
      获取指定字节数组的HEX表示形式(每个字节用空格分隔)
      参数:
      bytes - 字节数组
      返回:
      返回指定字节数组的HEX表示形式(每个字节用空格分隔)