2017-03-20 35 views
-2

我正在尋找一種方式或多種方式(總是好的,知道很多方法)如何將文本(字符串)轉換爲十六進制這樣http://codebeautify.org/string-hex-converter如何將文本轉換爲HexaDecimal?

任何幫助,將不勝感激。 我一直在不同的地方尋找小時,到目前爲止我還沒有找到可以爲我做這件事的代碼。

可以完成這項工作的所有方法都被接受,我喜歡學習編碼。

+0

這難道不是一個:將字符串轉換爲十六進制在Java(http://stackoverflow.com/questions/如何將字符串轉換爲十六進制和十六進制字符串?](http://stackoverflow.com/questions/15020812/how-to-convert-string十六進制和十六進制字符串),甚至[我怎樣才能將一個字符串轉換爲十六進制Java](http://stackoverflow.com/questions/18946597/how-can-i-convert-a- string-into-hex-in-java) –

+0

你嘗試過什麼嗎?學習編碼的最好方法是編碼(並犯錯誤)。 – Nitish

+0

可能的重複[如何將字節數組轉換爲十六進制字符串,反之亦然?](http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string -and-反之亦然) – Kainix

回答

0

字符串轉換爲16進制:

Integer.decode(hexString); 

十六進制爲String:

Integer.toHexString(integer);