/**
* 字节数组转换为十六进制字符串
* @param datas byte[] 待转换数据
* @return String 已转换数据
*/
public static String bytes2HexString(byte[] datas) {
StringBuilder sb = new StringBuilder("");
for (byte b : datas) {
int i = b & 0xFF;//byte类型【8位】转换为int类型【32位】
String hex = Integer.toHexString(i);
if (hex.length() == 1) {
hex = '0' + hex;
}
sb.append(hex.toUpperCase());
}
return sb.toString();
}