我正在阅读一个文件并希望将文件存储到某些单词,在这个例子中“是”到 aHashMap of < Integer, document >.
但我被困住了HashMap
,这是我的思路。
BufferedReader in = new BufferedReader(new FileReader("filename.txt"));
String line;
int i = 0;
while ((line = in.readLine()) != null) {
if (!line.startwith("yes");{
//add line to hashMap[i]
i++;
}
System.out.println(hashMap[i]);
}
如何在“是”之前添加我的文本HashMap
?