/**
* 16进制转换为ASCII
*
* @param bytes 源数据
* @param offset 偏移量
* @param length 数据长度
* @return {@link String}
*/
public String convertHexToAscii(byte[] bytes, int offset, int length) {
StringBuilder sb = new StringBuilder();
int step = 2;
for (int k = 0; k < length; k++) {
String hex = HexUtil.toHex(bytes[offset + k]);
for (int i = 0; i < hex.length() - 1; i += step) {
String output = hex.substring(i, (i + step));
int decimal = Integer.parseInt(output, 16);
sb.append((char) decimal);
}
}
return sb.toString();
}
标签:java,String,16,int,hex,param,length,ASCII
From: https://www.cnblogs.com/qiutian-hao/p/18103067