// 转换十六进制编码为字节数组。可以再转为字符串
public static byte[] toStringHex(String s) {
try {
if ("0x".equals(s.substring(0, 2))) {
s = s.substring(2);
}
byte[] baKeyword = new byte[s.length() / 2];
for (int i = 0; i < baKeyword.length; i++) {
try {
baKeyword[i]=(byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16));
} catch (Exception e) {
e.printStackTrace();
}
public static byte[] toStringHex(String s) {
try {
if ("0x".equals(s.substring(0, 2))) {
s = s.substring(2);
}
byte[] baKeyword = new byte[s.length() / 2];
for (int i = 0; i < baKeyword.length; i++) {
try {
baKeyword[i]=(byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16));
} catch (Exception e) {
e.printStackTrace();
}