我的txt文件看起來像:閱讀txt文件,每一列在java中添加不同的陣列
1,2,6,8,10,3
0,3,5,0
0,1
1,6,90,6,7
例如:
陣列0將包含:1,2,6,8,10,3
陣列1將包含:0,3,5,0
哪能去做?
我的代碼:
File file = new File("src/maze.txt");
try (FileInputStream fis = new FileInputStream(file)) {
// Read the maze from the input file
ArrayList column1array = new ArrayList();
ArrayList column2array = new ArrayList();
while ((content = fis.read()) != -1) {
char c = (char) content;
column1array.add(c);
}
}
謝謝Dershan –