Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Exception in thread "main" java.lang.NumberFormatException:

807606Jan 19 2007 — edited Apr 26 2007
Hi,
I am facing some errors in my codes anyone can see where does the problem come from? Thanks....
The exception is Exception in thread "main" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:468)
at java.lang.Integer.parseInt(Integer.java:497)

try{
FileReader frStream = new FileReader(fileName);
BufferedReader brStream = new BufferedReader(frStream);
int currentLine=1;
while((line = brStream.readLine())!=null){
switch(currentLine)
{
case 1: pos = line.indexOf("=")+1;
accId = Integer.parseInt(line.substring(pos).trim());
break;
case 2: pos = line.indexOf("=")+1;
name = line.substring(pos).toUpperCase().trim();
break;
case 3: pos = line.indexOf("=")+1;
address = line.substring(pos).trim();
break;
case 4: pos = line.indexOf("=")+1;
DOB = line.substring(pos).trim();
break;
case 5: pos = line.indexOf("=")+1;
phoneNo = line.substring(pos).trim();
break;
case 6: pos = line.indexOf("=")+1;
balance = Double.parseDouble(line.substring(pos).trim());
Customer1[customers] =
new Customer(accId,name,address,DOB,phoneNo,balance);
customers++;
break;
}
currentLine++;
}
System.out.println("Number of records added -> "+customers);
brStream.close();
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 24 2007
Added on Jan 19 2007
4 comments
338 views