2016-08-01 99 views
-4

任何人都可以請幫助我將字符串轉換爲十六進制和十六進制字符串爲以下字符串在阿拉伯語和英語。轉換字符串爲十六進制,反之亦然

String str = "مصطلحات : RAM : Random"; 
+2

的可能的複製[如何字符串轉換爲十六進制和十六進制轉換爲字符串?](http://stackoverflow.com/questions/15020812/how將字符串轉換爲十六進制和十六進制字符串) – sinclair

回答

2
byte[] myBytes = "مصطلحات : RAM : Random".getBytes("UTF-8"); 
String hexString = DatatypeConverter.printHexBinary(myBytes); // to hex String 

byte[] bytes = Hex.decodeHex(hexString.toCharArray()); 
new String(bytes, "UTF-8"); // decode it back 

我用這個questionanswer

+0

謝謝#Rudziankou會試一試。 –

相關問題