aspose file tools*
The moose likes Beginning Java and the fly likes please review- NumberFormatException in Conversation of String to Hexadecimal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "please review- NumberFormatException in Conversation of String to Hexadecimal" Watch "please review- NumberFormatException in Conversation of String to Hexadecimal" New topic
Author

please review- NumberFormatException in Conversation of String to Hexadecimal

Babu Singh
Ranch Hand

Joined: Aug 17, 2009
Posts: 78




Ouput:
java.lang.NumberFormatException: For input string: "0cv"
Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
I think you need to learn a bit about Hex numbers

0 1 2 3 4 5 6 7 8 9 A B C D E F

there is no V in a hex number, so you get the exception.


Omar Al Kababji - Electrical & Computer Engineer
[SCJP - 90% - Story] [SCWCD - 94% - Story] [SCBCD - 80% - Story] | My Blog
Babu Singh
Ranch Hand

Joined: Aug 17, 2009
Posts: 78
Dear Sir,

thanks for your reply.

when i give input String s = "12345678";
Output is: Hex Value of: 12345678 = 305419896

when i give input String s = "123456789";
Output is: java.lang.NumberFormaatException: For input string: "123456789"
Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
ok this is another issue now your problem is that

123456789 Hex = 4886718345 in Decimal and this value is too big to fit in an integer, so use a long instead of int

Long.parseLong();
Babu Singh
Ranch Hand

Joined: Aug 17, 2009
Posts: 78
Dear Sir,

thank you to resolve my queries.


Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
No problem
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: please review- NumberFormatException in Conversation of String to Hexadecimal