public class ByteUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static byte |
BIT |
| 构造器和说明 |
|---|
ByteUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
bytes2int(byte[] bytes)
4位字节数组转换为数字
|
static short |
bytes2short(byte[] bytes)
2位的字节数组转换为短数字
|
static boolean |
check(byte b,
int pos)
检查Byte数据的指定位置的数据
|
static byte[] |
fetch(byte[] source,
int start,
int length)
从字节数组中提取一段数组
|
static byte[] |
hexToBytes(String hexStr)
将十六进制转换为字节数组
|
static byte[] |
int2bytes(int num)
数字转换为4位字节数组
|
static byte[] |
long2bytes(long num) |
static byte[] |
merge(byte[]... bytes)
对多个字节数组进行合并
|
static byte[] |
read(InputStream input) |
static byte |
setBitInfo(byte b,
boolean value,
int pos)
将Byte数据的指定位置设置为true或false
|
static byte |
setFalse(byte b,
int pos)
将Byte数据的指定位置设置为False
|
static byte |
setTrue(byte b,
int pos)
将Byte数据的指定位置设置为True
|
static byte[] |
short2bytes(short num)
短数字转换为2位的字节数组
|
static String |
toHex(byte[] bytes)
将二进制转换为十六进制字符输出
|
static byte[] |
xor(byte[] bytes,
byte b)
循环对每个字节做异或操作
|
public static final byte BIT
public static String toHex(byte[] bytes)
bytes - 二进制public static byte[] hexToBytes(String hexStr)
hexStr - 十六进制字符串public static byte setBitInfo(byte b,
boolean value,
int pos)
b - 数据value - 需要设置的值pos - 位置(不能操作BIT的长度 8)public static byte setTrue(byte b,
int pos)
b - 数据pos - 位置public static byte setFalse(byte b,
int pos)
b - 数据pos - 位置public static boolean check(byte b,
int pos)
b - 数据pos - 位置public static byte[] short2bytes(short num)
num - 数字public static short bytes2short(byte[] bytes)
bytes - 2位字节数组public static byte[] int2bytes(int num)
num - 数字public static byte[] long2bytes(long num)
public static int bytes2int(byte[] bytes)
bytes - 4位字节数组public static byte[] xor(byte[] bytes,
byte b)
bytes - 字节数组b - 异或字节public static byte[] fetch(byte[] source,
int start,
int length)
source - 源数组start - 开始位置length - 提取长度public static byte[] merge(byte[]... bytes)
bytes - 多个字节数组public static byte[] read(InputStream input) throws IOException
IOExceptionCopyright © 2022. All rights reserved.