I have a file with many hexadecimal numbers (e.g. - 0X3B4). I am trying to parse this file how to assign these numbers to integers, but Integer.parseInt does not seem to work.
int testint = Integer.parseInt("3B4",16); <- WORKS
int testint = Integer.parseInt("0X3B4",16);
gives an error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "0x3b4"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
What is the correct way to set the value 0XB4 to int?
I have to get rid of 0X - it's not uncommon to represent hexagons this way ...
source
share