Conversion string is hexadecimal-encoded public static string tohexstring (string s) {string str= ' "; for (int i=0;i<s.length (); i++) {int ch = (i NT) S.charat (i); String s4 = integer.tohexstring (CH); str = str + s4; Return "0x" + str;//0x represents hexadecimal}//convert hexadecimal encoding to string public static string Tostringhex (string s) {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 ();}} try {s = new String (Bakeyword, "Utf-8");//utf-16le:not} catch (Exception E1) {e1.printstacktrace ();} return s; //=====================//below do a test public static void main (string[] args) throws Exception {String str = "Test"; Printhex String (Str.getbytes ()); public static void Printhexstring (byte[] b) {for (int i = 0; i < b.length; i++) {String hex = integer.tohexstring ( B[i] & 0xFF); if (hex.length () = = 1) {hex = ' 0 ' + Hex } System.out.print (Hex.touppercase ()); ///Output results: 74657374