Results 1 to 4 of 4
- 01-09-2012, 05:20 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 1
- Rep Power
- 0
Exception while converting string to integer
Hello friends,
I am trying to convert string to Int but i am getting exception as java.lang.NumberFormatException: For input string: ""
Code is as follows
String no=request.getParameter(itemno); // here itemno varies everytime...sometime it will be 1 and sometime it will be 2 but in string format
String itemn[]=no.split(" ");
int itemNo=Integer.parseInt(itemn[0]);
Can anyone solve this problem for me??
Thanks in advance
- 01-09-2012, 06:27 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,448
- Rep Power
- 16
Re: Exception while converting string to integer
Why are you doing the split?
Print out the value of 'no', like:
System.out.println(">" + no + "<");
SO you can spot spaces etc.
- 01-09-2012, 08:34 PM #3
Re: Exception while converting string to integer
Why do they call it rush hour when nothing moves? - Robin Williams
- 01-11-2012, 05:06 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Re: Exception while converting string to integer
Since OP get the solution he'll never come back, as usual.
Similar Threads
-
Converting J001 to integer
By jaylimix in forum New To JavaReplies: 4Last Post: 12-15-2011, 11:08 PM -
converting a given positive integer m to a positional number system in base n
By Renxx in forum New To JavaReplies: 2Last Post: 11-27-2011, 05:11 PM -
Converting a 2's complement to the proper integer
By Chuklol in forum New To JavaReplies: 1Last Post: 10-10-2011, 05:47 AM -
Converting an integer into a BigInteger
By mzjazzygirl in forum New To JavaReplies: 27Last Post: 09-23-2010, 06:37 PM -
[SOLVED] [newbie] converting Integer to java.lang.Enum.Modifier
By jon80 in forum New To JavaReplies: 24Last Post: 05-18-2009, 10:23 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks