1 //转化字符串为十六进制编码
2 public staticString toHexString(String s) {3 String str = "";4 for (int i = 0; i < s.length(); i++) {5 int ch = (int) s.charAt(i);6 String s4 =Integer.toHexString(ch);7 str = str +s4;8 }9 returnstr;10 }11 //转化十六进制编码为字符串
12 public staticString toStringHex1(String s) {13 byte[] baKeyword = new byte[s.length() / 2];14 for (int i = 0; i < baKeyword.length; i++) {15 try{16 baKeyword[i] = (byte) (0xff &Integer.parseInt(s.substring(17 i * 2, i * 2 + 2), 16));18 } catch(Exception e) {19 e.printStackTrace();20 }21 }22 try{23 s = new String(baKeyword, "utf-8");//UTF-16le:Not
24 } catch(Exception e1) {25 e1.printStackTrace();26 }27 returns;28 }29 //转化十六进制编码为字符串
30 public staticString toStringHex2(String s) {31 byte[] baKeyword = new byte[s.length() / 2];32 for (int i = 0; i < baKeyword.length; i++) {33 tr