【发布时间】:2015-03-24 15:24:58
【问题描述】:
我在文本文件中有整数,全部用空格分隔。
我知道如何读取文件,但我不知道如何将整数放入数组中。我知道我必须在某处使用parseInt。
阵列是 4x4。整数是:
2 1 4 2
9 7 5 3
9 8 3 5
1 0 0 0
我的代码:
arr = new int [4][4];
IODialog input = new IODialog();
String location = input.readLine("Enter the full path of the configuration text file: ");
Scanner scn = null;
try {
scn = new Scanner(new BufferedReader(new FileReader(location)));
int i, j = 0;
String line = scn.nextLine();
String[] numbers = line.split(" ");
} finally {
if (scn != null) {
scn.close();
}
}
【问题讨论】:
-
即使是年轻的巫师也必须展示一些初步的工作——你已经走了多远?