BufferedReader br2 = new BufferedReader(
new InputStreamReader(new FileInputStream(id_zastavky), "windows-1250")
);
for (int i = 0; i < id_linky_list.size(); i++)
{
while ((sCurrentLine2 = br2.readLine()) != null)
{
String pom = id_linky_list.get(i);
String[] result = sCurrentLine2.split("\\|");
if((result[1].toString()).equals(pom.toString()))
{
System.out.println(result[1].toString()+" " +pom.toString() + " " + result[3]);
}
}
}
br2.close();
嘿傢伙。任何人都可以給我建議爲什麼我的FOR循環僅使用id_linky_list中的第一項然後退出?我認爲這個問題是在這條線在txt文件中多個字符串搜索(java)
,而((sCurrentLine2 = br2.readLine())!= NULL)
。我的列表中有超過5000個項目,如果它們存在於我的txt文件中,我需要對它們進行比較。如果我運行我的應用程序for循環只需要第一個項目。我應該如何修改我的代碼才能正常工作?感謝您的任何幫助。
'流線=文件.lines(file.toPath(),Charset.from(「windows-1250」));'而不是'linesOf'或'readAllLines'。 –
@JoopEggen謝謝你,我從其他軟件包導入了錯誤的'Files',更新了答案 – Saravana