How to Convert String to Hexa Value ?

hi,i want to convert String value to Hexa Value.so, how i can do that ?my String value len is 20.i.e.String str = "31080601090620003453";so, how i convert this value to hexa value..pls, help me....
[253 byte] By [sachin_katariaa] at [2007-10-3 3:57:58]
# 1
A String is a bunch of characters. How is it supposed to be a hex value? You need to be a little more specific.31080601090620003453 -> AF547A051406147D?If so, look at the Long class.
CeciNEstPasUnProgrammeura at 2007-7-14 21:56:24 > top of Java-index,Java Essentials,Java Programming...
# 2
Check this tip: http://www.java-tips.org/java-se-tips/java.lang/conversion-from-decimal-to-hexadecimal.html
casperla at 2007-7-14 21:56:24 > top of Java-index,Java Essentials,Java Programming...
# 3

There's no built-in function to convert a string of hex to a byte array, unfortunately. And using the Integer method it remarkably messy, because of the odd character length problem etc.. It's probably easier to write it yourself using Character.digit() with a little shifting and orring.

There's a class for it in the apache commons "Codec" library.

malcolmmca at 2007-7-14 21:56:24 > top of Java-index,Java Essentials,Java Programming...
# 4
Integer.toHexString(Integer.parseInt(mystring)).toUpperCase()
Dick_Adamsa at 2007-7-14 21:56:24 > top of Java-index,Java Essentials,Java Programming...
# 5
> Integer.toHexString(Integer.parseInt(mystring)).> toUpperCase()With 20 hex nybles? Hardly
malcolmmca at 2007-7-14 21:56:24 > top of Java-index,Java Essentials,Java Programming...
# 6
i already tried that.....but, integer cant suppert len of 20...so, how i can do that ?pls , help me...........
sachin_katariaa at 2007-7-14 21:56:24 > top of Java-index,Java Essentials,Java Programming...
# 7
new BigInteger("63904769238836211").toString(16)
DrClapa at 2007-7-14 21:56:24 > top of Java-index,Java Essentials,Java Programming...