public class BytesUtils extends Object
| 构造器和说明 |
|---|
BytesUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
binToHex(byte[] bin)
将字节集转换为16进制
|
static String |
binToHex(byte[] bin,
boolean format)
将字节集转换16进制
|
static int |
binToInt(byte[] b)
将字节集转换为int类型
|
static long |
binToLong(byte[] b)
将字节集转换为long类
|
static short |
binToShort(byte[] b)
将字节集转换为short类型
|
static <T> T |
bytesToObject(byte[] buffer)
字节集到对象
|
static byte[] |
fillCode(byte[] bin)
填充算法,将字节集填充到8的整数倍
|
static int |
find(byte[] bin,
byte[] queryBin)
从一个字节中查询出现的字节
|
static int |
findLast(byte[] bin,
byte[] queryBin)
倒找字节集
|
static byte[] |
hexToBin(String hex)
十六进制转换为字节集
|
static byte[] |
intToBin(int i,
int size)
将int类转字节集
|
static boolean |
isEquery(byte[] bin1,
byte[] bin2)
两个字节集数组是否相等
|
static byte[] |
longToBin(long l,
int size)
将long类转字节集
|
static byte[] |
merge(byte[] bin1,
byte[]... bins)
合并两个字节集
|
static byte[] |
objectToBytes(Object object)
对象到字节集
|
static byte[] |
shortToBin(short i,
int size)
将short类型转换为字节集
|
static byte[] |
subBytes(byte[] bin,
int start,
int end)
取字节集中间
|
static byte[] |
unFillCode(byte[] bin)
将填充算法的数据还原
|
public static byte[] fillCode(byte[] bin)
throws IOException
bin - IOExceptionpublic static byte[] unFillCode(byte[] bin)
throws IOException
bin - IOExceptionpublic static int findLast(byte[] bin,
byte[] queryBin)
bin - queryBin - public static int find(byte[] bin,
byte[] queryBin)
bin - queryBin - public static boolean isEquery(byte[] bin1,
byte[] bin2)
bin1 - bin2 - public static byte[] subBytes(byte[] bin,
int start,
int end)
bin - start - end - public static long binToLong(byte[] b)
b - public static int binToInt(byte[] b)
b - public static short binToShort(byte[] b)
b - public static byte[] longToBin(long l,
int size)
throws IOException
l - size - 保证长度IOExceptionpublic static byte[] intToBin(int i,
int size)
throws IOException
IOExceptionNumberFormatExceptionpublic static byte[] shortToBin(short i,
int size)
throws IOException
i - size - IOExceptionpublic static String binToHex(byte[] bin)
bin - public static String binToHex(byte[] bin, boolean format)
bin - format - 格式化显示public static byte[] hexToBin(String hex) throws IOException
hex - IOExceptionpublic static byte[] merge(byte[] bin1,
byte[]... bins)
throws IOException
bin1 - bins - IOExceptionpublic static byte[] objectToBytes(Object object) throws IOException
object - IOExceptionpublic static <T> T bytesToObject(byte[] buffer)
throws IOException,
ClassNotFoundException
buffer - IOExceptionClassNotFoundExceptionCopyright © 2022. All rights reserved.