> I want to read from a file called scores.txt this is all it contains
>
[quoted text clipped - 68 lines]
>
> }
When i had to do something like this for homework I just used the
split() method while reading one whole line at a time.
public String nflStats[][] = new String[numPlayers][numAttributes];
NFLStats() {
BufferedReader input = null;
int plyrcnt = 0;
try {
input = new BufferedReader(new FileReader("nfl.csv"));
}
catch (FileNotFoundException e) {
System.out.println("File nfl.csv not found");
}
//Parse file, split each line using a , as the field separator.
//Each token gets put into the nflStats array by player
//Fields in file assumed to be comma delimited and in the
//following order:
//number, Lname, Fname, position, years exp., school attended, team
try {
String lineFromFile = null;
while (plyrcnt < nflStats.length) {
lineFromFile = input.readLine();
String[] playerData = lineFromFile.split(",");
for (int attribute = 0; attribute <
numAttributes; attribute++) {
nflStats[plyrcnt][attribute] =
playerData[attribute];
}
plyrcnt++;
}
} catch (IOException IOex) {
System.out.println(IOex.getMessage());
}
} //end NFLStats()