我在讀整個文件,如果它包含特定的字符串,我想使用該行。我無法使用字符串,因爲它在while循環外面打印null
,儘管事實上我已經在循環之外初始化了它。訪問值While While循環
FileInputStream wf = new FileInputStream(pr.getSplitDir() + listfiles[i]);
BufferedReader wbf = new BufferedReader(new InputStreamReader(wf));
String wfl = "";
while ((wfl = wbf.readLine()) != null) {
if (wfl.contains("A/C NO:")){
// System.out.println(wfl); // Here it is Printing the correct line
}
}
System.out.println(wfl); // Here it is printing null
請幫忙。