public class ByteUtil extends Object
| Constructor and Description |
|---|
ByteUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
bcdBytes2Int(byte... bs)
将字节数组按BCD解码成10进制的Int类型
|
static String |
bcdBytes2Str(byte... bs)
将字节数组按BCD解码成10进制的String类型
|
static String |
bcdBytes2Str(byte b)
将一个字节按BCD解码成10进制的String类型
|
static int |
bytes2Int(byte... b)
转换从字节数组中0索引开始的4个字节为Int类型
|
static int |
bytes2Int(byte[] b,
int pos)
转换从字节数组中pos索引开始的4个字节为Int类型
|
static int |
bytes2Int(byte[] b,
int pos,
int len)
转换从字节数组中pos索引开始的len个字节为Int类型
|
static long |
bytes2long(byte[] bs)
将8字节的byte数组转成一个long值
|
static int |
charAtReverseNot0(byte[] bytes)
返回bytes数组中从后向前第一个不是0的下标值
|
static byte[] |
double2bytes(double v,
int len) |
static byte[] |
getBytesGBK(String src)
GBK编码
|
static byte[] |
int2bytes(int v,
int len)
Int转换为字节数组,如果转换的字节长度小于4,则忽略相应高位字节
|
static byte[] |
join(byte[] s,
byte[] d)
合并两个byte数组
|
static byte[] |
long2bytes(long v)
将64位的long值放到8字节的byte数组
|
static byte[] |
long2bytes(long v,
int len) |
static boolean |
startsWith(byte[] src,
byte[] starts)
判断部分字节内容相等
|
static byte[] |
str2bcdBytes(String radix10Str,
int len)
10进制字符串转换成BCD编码的字节
|
static byte[] |
str2bcdBytes(String radix10Str,
int len,
int additional)
10进制字符串转换成BCD编码的字节
|
static byte[] |
toBytes4HexString(String str) |
static String |
toHexString(byte... bytes)
将字节以16进制字符串显示
|
static String |
toHexString(byte[] bytes,
char separated,
int pos,
int len)
将字节以16进制字符串显示
|
static String |
toHexString(ByteBuffer buf) |
static String |
toHexString(ByteBuffer buf,
int pos,
int len) |
public static byte[] getBytesGBK(String src)
src - 操作源public static boolean startsWith(byte[] src,
byte[] starts)
src - bytes 源starts - 对比对象public static byte[] long2bytes(long v,
int len)
public static byte[] double2bytes(double v,
int len)
public static byte[] long2bytes(long v)
v - 数值public static long bytes2long(byte[] bs)
bs - byteArraypublic static byte[] int2bytes(int v,
int len)
throws IllegalArgumentException
v - 值len - 转换后的字节长度IllegalArgumentExceptionpublic static int bytes2Int(byte... b)
throws NullPointerException,
IllegalArgumentException
b - 数组NullPointerException - 数组为空IllegalArgumentException - 转换错误public static int bytes2Int(byte[] b,
int pos)
throws NullPointerException,
IllegalArgumentException
b - 数组pos - 索引NullPointerException - 数组为空IllegalArgumentException - 转换错误public static int bytes2Int(byte[] b,
int pos,
int len)
b - 数组pos - 索引len - 小于等于4字节public static int bcdBytes2Int(byte... bs)
throws NullPointerException,
IllegalArgumentException
bs - 数组NullPointerException - 数组为空IllegalArgumentException - 转换错误public static String bcdBytes2Str(byte b) throws IllegalArgumentException
b - 值IllegalArgumentException - 转换错误public static String bcdBytes2Str(byte... bs) throws IllegalArgumentException
bs - 数组IllegalArgumentException - 转换错误public static byte[] str2bcdBytes(String radix10Str, int len)
radix10Str - 值len - 字节长度public static byte[] str2bcdBytes(String radix10Str, int len, int additional)
radix10Str - 数值len - 字节长度additional - 位数不足时补充的内容(前面填充)public static byte[] join(byte[] s,
byte[] d)
s - 源d - 源2public static int charAtReverseNot0(byte[] bytes)
bytes - 数组public static String toHexString(byte... bytes)
bytes - 数组public static String toHexString(byte[] bytes, char separated, int pos, int len)
bytes - 数组separated - 数组pos - 数组len - 数组public static String toHexString(ByteBuffer buf)
public static String toHexString(ByteBuffer buf, int pos, int len)
public static byte[] toBytes4HexString(String str)
Copyright © 2017. All rights reserved.