This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes java.lang.NumberFormatException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java.lang.NumberFormatException" Watch "java.lang.NumberFormatException" New topic
Author

java.lang.NumberFormatException

nikil shar
Ranch Hand

Joined: May 25, 2008
Posts: 116
hi all,
i get this error when trying to parse a string :

java.lang.NumberFormatException: For input string: "12345501297"




i dont see why it throws this error ??

thanks in advance.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3816

The value you are trying to parse is too large for "int" type. Check with "Integer.MAX_VALUE".


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
chandrakant karale
Ranch Hand

Joined: Nov 21, 2007
Posts: 41


If you are dealing with large account numbers, use long as datatype; replace Integer.parseInt by Long.parseLong.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

And if they still don't fit you have little option but to use BigInteger.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.NumberFormatException
 
Similar Threads
javax.servlet.jsp.JspException in Application
parseInt throwing exception
Lost, need help
loading an integer data file into an integer array
Session in jsp