我正在閱讀文件,並希望將文件存儲起來直到某個單詞,在本例中爲'yes'爲HashMap of < Integer, document >.
但我被卡住了HashMap
,這是我的思路。將文件的片段放入HashMap中 - Java
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
中添加我的文字直到'是'?
什麼是你的問題? – Sap 2012-08-08 05:49:49