0
我一直在嘗試使用列表來存儲來自.csv文件的數據,但由於我是新來的使用列表,我似乎無法得到它上班。我搜索了很多教程,但他們都沒有爲我工作。我肯定錯過了什麼。這是我到目前爲止有:使用列表來存儲來自BufferedReader文件的數據
int row = 0;
int col = 0;
String fileInput = JOptionPane.showInputDialog(null,
"Please enter the path of the CSV file to read:");
File file = new File(fileInput);
BufferedReader bufRdr;
bufRdr = new BufferedReader(new FileReader(file));
String line = null;
ArrayList<String[]> arrayOfNumbers = new ArrayList<String[]>();
//read each line of text file
while((line = bufRdr.readLine()) != null) {
StringTokenizer st = new StringTokenizer(line,",");
col=0;
while (st.hasMoreTokens()) {
//get next token and store it in the array
// UNSURE WHAT TO PUT HERE
}
row++;
}
然後我想在列表中的數據存儲到一個多維數組稱爲String[][] numbers
。我應該做什麼的想法?