Originally Posted by
javaAddict
Look at your code:
for (line = lnr.readLine(); line!=null; line = lnr.readLine()){
String account[] = new String[4];
int count = 0;
int accountNumber[] = Integer.parseInt(account[count][1]);
int pinNumber[] = Integer.parseInt(account[count][2];
int balance[] = Integer.parseInt(account[count][3];
String name = account[count][4];
System.out.println(accountNumber[0][1]);
}
You read the line BUT inside the loop you don't do anything with it. Instead you call this:
Integer.parseInt(account[count][1]); .
The account array is not 2-D and the Integer.parseInt does not return an array.
Now inside the line you have something like this:
12345 1234 200000 Jerry Lopez
So If you use the split method:
String [] array = line.split(" ");
The elements of the array would be:
0: 12345
1: 1234
2: 200000
3: Jerry
4: Lopez
Also for reading from a file try this shorter version:
BufferedReader lnr = new BufferedReader (new FileReader("accountList.txt"));
oh,,thank you very much for the help guyzz,,,this will be a great help...
ah now i see,,,
so if i will use string.split...
how will i declare the variables?????will it be the same with what i did???...i am really confused anyway...