我在试图读入数组的文件中的一行中有一个空格分隔的 36 个数字列表。我的程序读取整行,但只添加了 18 个数字。有人看到原因吗?
谢谢你。
StringTokenizer st;
try{
BufferedReader br = new BufferedReader(
new FileReader("Scores.txt"));
String line = br.readLine();
double avg = 0.0;
double sum = 0.0;
int count = 0;
while (line!=null)
{
st = new StringTokenizer(line);
System.out.println("Total tokens : " + st.countTokens());
for(int i = 0; i < st.countTokens(); i++)
{
avg += Double.parseDouble(st.nextToken());
count++;
System.out.println("i: " + i);
}
System.out.println(line);
line = br.readLine();
}
br.close();
sum = avg;
System.out.println("Sum: " + sum);
System.out.println("Count: " + count);
avg = avg/count;
System.out.println("Avg: " + avg);
}catch(Exception e)