Exception in thread "main" java.lang.NumberFormatException:
807606Jan 19 2007 — edited Apr 26 2007Hi,
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();
}