Convert a string representation of a hex dump to a byte array using Java?

Posted by ravigad on Stack Overflow See other posts from Stack Overflow or by ravigad
Published on 2008-09-26T15:12:45Z Indexed on 2010/03/15 15:49 UTC
Read the original article Hit count: 195

Filed under:
|
|
|

I am looking for a way to convert a long string (from a dump), that represents hex values into a byte array.

I couldn't have phrased it better than the person that posted the same question here:

http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21062554.html

But to keep it original, I'll phrase it my own way: suppose I have a string "00A0BF" that I would like interpreted as the byte[] {0x00,0xA0,0xBf} what should I do?

I am a Java novice and ended up using BigInteger and watching out for leading hex zeros. But I think it is ugly and I am sure I am missing something simple...

© Stack Overflow or respective owner

Related posts about java

Related posts about hexadecimal