//十六进制字符串转字符串
public static String hexStr2Str(String hexStr) {
//自己定义加的前缀 str
String str = "0123456789ABCDEF";
char[] hexs = hexStr.toCharArray();
byte[] bytes = new byte[hexStr.length() / 2];
int n;
for (int i = 0; i < bytes.length; i++) {
n = str.indexOf(hexs[2 * i]) * 16;
n += str.indexOf(hexs[2 * i + 1]);
bytes[i] = (byte) (n & 0xff);
}
return new String(bytes);
}
java 16进制转字符串
最新推荐文章于 2024-07-08 03:19:57 发布