类 ByteTools

java.lang.Object
com.walker.infrastructure.utils.ByteTools

public final class ByteTools extends Object
  • 构造器详细资料

    • ByteTools

      public ByteTools()
  • 方法详细资料

    • getRandomNum

      public static String getRandomNum(int intNumber)
      生成指定长度的随机数字符串
      参数:
      intNumber -
      返回:
    • byteHEX

      public static String byteHEX(byte ib)
      将一个字节以两位16进制数字表示成字符串
      参数:
      ib - 字节
      返回:
      字符串,两位
    • byte2int

      public static int byte2int(byte byHi, byte byLo)
      2byte => 1int
      参数:
      byHi -
      byLo -
      返回:
      1 int
    • byte2int

      public static int byte2int(byte HH, byte HL, byte LH, byte LL)
      4byte => 1int
      参数:
      HH -
      HL -
      LH -
      LL -
      返回:
    • int2bytes

      public static byte[] int2bytes(int i)
      int 转换为 byte 数组
      参数:
      i -
      返回:
    • int2bytes2

      public static byte[] int2bytes2(int i)
    • bytes2int

      public static int bytes2int(byte[] b)
      byte[4] 转化为int
      参数:
      b - byte[4]
      返回:
      int
    • getName

      public static String getName(String s)
      从一个路径得到文件名
      参数:
      s -
      返回:
    • randomByte

      public static byte[] randomByte()
      生成一个唯一的16位的字符串——16进制byte
    • cip2bytes

      public static byte[] cip2bytes(String ip)
    • ip2bytes

      public static byte[] ip2bytes(String ip)
    • bytes2ip

      public static String bytes2ip(byte[] packet)
      4个字节的byte[]转变为IP地址
    • hexStr2byteArr

      public static byte[] hexStr2byteArr(String hex)
      16进制字符串转换为byte []
      参数:
      hex -
      返回:
    • string2File

      public static boolean string2File(String res, String filePath)
      将字符串写入指定文件(当指定的父路径中文件夹不存在时,会最大限度去创建,以保证保存成功!)
      参数:
      res - 原字符串
      filePath - 文件路径
      返回:
      成功标记
    • Bytes2HexString

      public static String Bytes2HexString(byte[] b)
      将byte[]转化为16进制字符串
      参数:
      b - byte[]
      返回:
      16进制字符串
    • hBytesToInt

      public static int hBytesToInt(byte[] b)
      将高字节数组转换为int
      参数:
      b - byte[]
      返回:
      int
    • StringToLong

      public static long StringToLong(String ip)
      由IP形式的字符串转化为long
    • isIPv4

      public static boolean isIPv4(String value)
      判断字符串是否是IPv4地址
      参数:
      value -
      返回:
    • LongToString

      public static String LongToString(long lip)
      由long转化为IP形式的字符串
    • getID

      public static long getID()
      获得主键
      返回:
      主键
    • isIdentifier

      public static String isIdentifier(String identifier)