How to easily change the formatted string as & ldquo; 20 0F 01 & rdquo; in hexadecimal values ​​in Java?

advertisements

I've found method toHexString() but it converts string into hex, while the value is already converted (like "20 0F 01 etc."). What's the best way to get hex values from this String for later purposes (ex. adding, sending some of them to output device)?


Try

Integer.parseInt(String val, int radix)

Example Integer.parseInt("-FF", 16) returns -255

https://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html#parseInt(java.lang.String,%20int)