| Author |
Reading a file and getting run time error
|
Jithesh Kumar
Ranch Hand
Joined: Mar 09, 2010
Posts: 46
|
|
when i am reading a file and converting the string to integer it is giving me
java.lang.NumberFormatException:For input string:"" run time error
this is the code
BufferedReader leagueReader=new BufferedReader(new
FileReader(leagueFile));
String record;
while((record=leagueReader.readLine())!=null){
String del="|";
String[] fields=record.split(del);
int objectID=Integer.parseInt(fields[0]);---this line is giving the error.
int year=Integer.parseInt(fields[1]);
String season=fields[2];
String title=fields[3];
|
 |
Tim McGuire
Ranch Hand
Joined: Apr 30, 2003
Posts: 607
|
|
bon jith wrote:when i am reading a file and converting the string to integer it is giving me
java.lang.NumberFormatException:For input string:"" run time error
this is the code
Try outputing record and/or fields[0] on each loop in after the split() command. You will then probably see a missing piece of data. You will have to do a check on fields[0] to make sure it is not a blank string.
|
 |
 |
|
|
subject: Reading a file and getting run time error
|
|
|