我正在努力阅读大约200万条目的文件。并非所有都是有效的行,但这是上限。我正在使用Map来存储文件中的键值对。然而,我发现最后一个术语是在1932513行。我正在用Java编写eclipse,然后继续在eclipse.ini中提升Xmx参数。这并没有解决问题。这是我正在使用的代码:
BufferedReader bufferedRead = new BufferedReader(inputStream);
String data;
try {
while((data = bufferedRead.readLine()) != null) {
String[] meterReadings = data.split(";");
if("Date".equals(meterReadings[0])) continue;
/*
* Creating the key object using concatenation of date-time
*/
if(newApp.isEmpty(meterReadings)) continue;
List<Object> valueList = new ArrayList<Object>();
String[] subDate = meterReadings[0].split("/");
StringBuffer dateTime = new StringBuffer();
for(String s : subDate) {
dateTime.append(s + ":");
}
dateTime.append(meterReadings[1]);
for(int i=2; i < meterReadings.length -1; ++i) {
valueList.add(meterReadings[i]);
}
newApp.textMap.put(dateTime.toString(), valueList);
}
} catch (IOException e) {
log.error("Unable to read from file: ", App.DATA_DIR + App.FILENAME);
e.printStackTrace();
}
/*
* Checking to see if Map has been created
*/
System.out.println("*****************************************");
Set<String> newSet = newApp.textMap.keySet();
Object[] setArray = newSet.toArray();
System.out.println("The last term's key is : " + (String) setArray[setArray.length - 1]);
System.out.println(newApp.textMap.size());
log.info("The size of the reading is : ", newApp.textMap.size());
System.out.println("*****************************************");
}