我在 java 中遇到了 BufferedReader 的问题。我正在从大文件中逐行读取,解析行并插入 HashMap,但结果只有几行在 HashMap
Map< Integer, String> data = new HashMap<>(1000000);
int completedTestsCount = 0;
BufferedReader reader = new BufferedReader(new FileReader("file.txt"), 120000);
String line = null;
while ((line = reader.readLine()) != null) {
if (line.contains("START executing FOR"))
{
String tempId = line.substring(42, line.length() - 38);
int startId = Integer.parseInt(tempId);
String dateTime = line.substring(6, 14);
data.put(startId, dateTime);
}
这是我要解析的文件中的行示例“INFO 00:00:09 - START execution FOR test3625 at Mon Sep 23 00:00:09 GMT+00:00 2013”,所以键是测试 ID