How to read/convert hexidecimal string to an interger

Hello everyone,

This is probably very simple but non of my books show what I need to do. I am running Java 1.4.2 and not ready yet for 1.5.

I wanted to read Property entries containing hexidecimal entries and then convert the hexidecimal entries (which are in String format) into a number either int., long,double or Interger.

Property entry:

address=0x06FE

--

Property prop = new ....

String addr = prop.getProperty("address");

Interger num = new Interger.parseInt(addr); <- fails

Would appreciate your help

Regards,

Ulises

[601 byte] By [arsi@a] at [2007-10-2 9:13:01]
# 1
Integer.parseInt(addr, 16);//orInteger.valueOf(addr, 16);Note that you should call the method by the classname, as it's static. Do n't try to do new Integer as you're doing.
jverda at 2007-7-16 23:20:04 > top of Java-index,Java Essentials,Java Programming...
# 2
Great. thanks!
arsi@a at 2007-7-16 23:20:04 > top of Java-index,Java Essentials,Java Programming...
# 3
Sorry, is not working....I am getting NumberFormatException for input "0x600";
arsi@a at 2007-7-16 23:20:04 > top of Java-index,Java Essentials,Java Programming...
# 4
Get rid of the "0x" off the beginning.
jverda at 2007-7-16 23:20:04 > top of Java-index,Java Essentials,Java Programming...
# 5
THANKS! It worked like a champ!
arsi@a at 2007-7-16 23:20:04 > top of Java-index,Java Essentials,Java Programming...
# 6
Cool! Glad you got it working.
jverda at 2007-7-16 23:20:04 > top of Java-index,Java Essentials,Java Programming...