类 ByteUtils
- java.lang.Object
-
- network.nerve.core.model.ByteUtils
-
public class ByteUtils extends Object
- 作者:
- tag
-
-
构造器概要
构造器 构造器 说明 ByteUtils()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static booleanarrayEquals(byte[] array1, byte[] array2)比较两个字节数组是否相等static StringasString(byte[] value)将字节数组转为字符串static BigIntegerbytesToBigInteger(byte[] b)字节数组转BigIntegerstatic doublebytesToDouble(byte[] arr)把byte[]转doublestatic intbytesToInt(byte[] bytes)将字节数组转为整型数static shortbytesToShort(byte[] b)byte[]转shortstatic StringbytesToString(byte[] bytearray)字节数组转字符串static List<String>bytesToStrings(List<byte[]> byteList)字节数组列表转为字符串列表 Byte Array List to String Liststatic longbyteToLong(byte[] b)字节数组到long的转换.static bytecaculateXor(byte[] data)static byte[]concatenate(byte[]... arrays)按照传入的顺序拼接数组为一个包含所有数组的大数组 Splices the array into a large array containing all of the arrays in the incoming order.static booleancontains(List<byte[]> byteList, byte[] bytes)判断字节数组中是否包含某一个字节数组 Determine whether or not a byte array is included in the byte arraystatic byte[]copyOf(byte[] in, int length)字节数组复制static byte[]doubleToBytes(double d)把double转为bytestatic byte[]intToBytes(int num)将整型数转为对应的字节数组static booleanisEmptyOrNull(byte[] array)字节数组是否为空static byte[]longToBytes(long num)将长整型数转为对应的字节数组static byte[]reverseBytes(byte[] bytes)字节数组逆序static byte[]shortToBytes(short num)short到字节数组的转换.static byte[]subBytes(byte[] input, int startIndex, int length)截取字节数组static byte[]toBytes(CharSequence str, String charsetName)字符串按指定编码规则转为字节数组static StringtoString(byte[] bytes, String charsetName)字节数组按指定编码转为字符串
-
-
-
方法详细资料
-
concatenate
public static final byte[] concatenate(byte[]... arrays)
按照传入的顺序拼接数组为一个包含所有数组的大数组 Splices the array into a large array containing all of the arrays in the incoming order.- 参数:
arrays- 想要拼接的数组集合、A collection of arrays that you want to concatenate.- 返回:
- 拼接结果、 the result of the Joining together
-
isEmptyOrNull
public static final boolean isEmptyOrNull(byte[] array)
字节数组是否为空- 参数:
array- 校验的字节数组- 返回:
- 如果字节数组为null或长度为0返回true否则返回false
-
arrayEquals
public static boolean arrayEquals(byte[] array1, byte[] array2)比较两个字节数组是否相等- 参数:
array1- 需比较的字节数组array2- 需比较的字节数组- 返回:
-
caculateXor
public static byte caculateXor(byte[] data)
-
asString
public static String asString(byte[] value)
将字节数组转为字符串- 参数:
value- 需转换的字节数组- 返回:
- 直接数组转换得到的字符串
-
bytesToShort
public static short bytesToShort(byte[] b)
byte[]转short- 参数:
b- 字节数组
-
bytesToInt
public static int bytesToInt(byte[] bytes)
将字节数组转为整型数- 参数:
bytes- 需转换的字节数组- 返回:
- 转换得到的整型数
-
byteToLong
public static long byteToLong(byte[] b)
字节数组到long的转换.- 参数:
b- 字节数组
-
bytesToBigInteger
public static BigInteger bytesToBigInteger(byte[] b)
字节数组转BigInteger- 参数:
b- 需转换在字节数组- 返回:
- BigInteger
-
bytesToString
public static String bytesToString(byte[] bytearray)
字节数组转字符串- 参数:
bytearray- 字节数组- 返回:
- 转换都的字符串
-
bytesToDouble
public static double bytesToDouble(byte[] arr)
把byte[]转double- 返回:
- double
-
shortToBytes
public static byte[] shortToBytes(short num)
short到字节数组的转换.- 参数:
num- 需转换的整型数
-
intToBytes
public static byte[] intToBytes(int num)
将整型数转为对应的字节数组- 参数:
num- 需转换的整型数- 返回:
- 转换后的字节数组
-
longToBytes
public static byte[] longToBytes(long num)
将长整型数转为对应的字节数组- 参数:
num- 需转换的长整型数- 返回:
- 转换后得到的字节数组
-
doubleToBytes
public static byte[] doubleToBytes(double d)
把double转为byte- 返回:
- byte[]
-
subBytes
public static byte[] subBytes(byte[] input, int startIndex, int length)截取字节数组- 参数:
input- 源字节数组startIndex- 开始截取的下标length- 截取的长度- 返回:
- 截取出的自己数组
-
reverseBytes
public static byte[] reverseBytes(byte[] bytes)
字节数组逆序- 参数:
bytes- 源字节数组- 返回:
- 逆序字节数组
-
copyOf
public static byte[] copyOf(byte[] in, int length)字节数组复制- 参数:
in- 源字节数组length- 复制的长度- 返回:
- 复制出的字节数组
-
toString
public static String toString(byte[] bytes, String charsetName)
字节数组按指定编码转为字符串- 参数:
bytes- 字节数组charsetName- 编码规则
-
toBytes
public static byte[] toBytes(CharSequence str, String charsetName)
字符串按指定编码规则转为字节数组- 参数:
str- 字符串charsetName- 编码规则
-
contains
public static boolean contains(List<byte[]> byteList, byte[] bytes)
判断字节数组中是否包含某一个字节数组 Determine whether or not a byte array is included in the byte array- 参数:
byteList-bytes-
-
-