我想在java中讀取CSV文件並將此數據存儲在數組中以便能夠在另一個函數中使用此數據進行搜索。從csv文件存儲中讀取數據並使用java中的這些數據進行搜索
public ArrayList <Resp> processTextToRespList(String filePath) throws IOException {
ArrayList <data> result = new ArrayList <data>();
br = new BufferedReader(new FileReader(csvFile));
while((row = BufferedReader.readNext()) != null) {
String line = scan.nextLine();
String[][] lineArray = line.split(" ");
result.add(new esp(lineArray[0], lineArray[1], lineArray[2]));
}
return result;
}
什麼是您的搜索條件? – Maverick
它是一個ldap搜索。但即時通訊與我在位,我只是不能讓我的頭讀取文件和存儲信息,所以我可以做每一行上的搜索。 – step
如果是鍵值對文件,則使用Map代替ArrayList,因爲在搜索的情況下檢索速度會快得多。 – Maverick