Number format problem
Hi
My code doesnt work.
And i hope you can tell me why.
This is a method in my acc class.
publicvoid setAccount(String name){
try
{
BufferedReader in =new BufferedReader(new FileReader(name));
for (int itr = 0; itr < maxlines; itr++){
if (itr == 0){
levelstring = in.readLine();
levelstring.trim();
}
elseif (itr == 1){
xpstring = in.readLine();
xpstring.trim();
}
elseif (itr == 2){
hairstylestring = in.readLine();
hairstylestring.trim();
}
elseif (itr == 3){
haircolorstring = in.readLine();
haircolorstring.trim();
}
elseif (itr == 4){
genderstring = in.readLine();
genderstring.trim();
}
elseif (itr == 5){
shirtstring = in.readLine();
shirtstring.trim();
}
elseif (itr == 6){
legsstring = in.readLine();
legsstring.trim();
}
elseif (itr == 7){
xstring = in.readLine();
xstring.trim();
}
elseif (itr == 8){
ystring = in.readLine();
ystring.trim();
}
}
in.close();
}
catch (Exception e)
{
System.out.println("Cannot find Account");
}
xp= Integer.parseInt(xpstring);
level= Integer.parseInt(levelstring);
hairstyle= Integer.parseInt(hairstylestring);
haircolor= Integer.parseInt(haircolorstring);
gender= Integer.parseInt(genderstring);
shirt= Integer.parseInt(shirtstring);
legs= Integer.parseInt(legsstring);
x= Integer.parseInt(xstring);
y= Integer.parseInt(ystring);
}
When i call this method the compiler says:
Exception in thread "main" java.lang.NumberFormatException: null
at java.lang.Integer.parseIny(Unknown Source)
at java.lang.Integer.parseIny(Unknown Source)
at acc.setAccount(acc.java:162)
at main.main(main.java:63)
The file that the program should read from looks like this
1
5431
4
2
1
5
1
53
24
Somebody plz help me
Message was edited by:
javaguy387

