怎么把16进制字符串转换成ascii码

2024-12-05 08:43:04
推荐回答(1个)
回答1:

String s = "abcd";
byte[] b = s.getBytes();
int[] in = new int[b.length];
for (int i = 0; i < in.length; i++) {
in[i] = b[i]&0xff;
}
for (int j = 0; j < in.length; j++) {
System.out.println(Integer.toString(in[j], 0x10));
}