1
我有(只發生與XLSX文件)會拋出這個錯誤的應用程序:空指針(java.io.File的)異常,而調試dissappears
java.lang.NullPointerException
at java.io.File.<init>(File.java:222)
at de.mpicbg.tds.core.ExcelLayout.openWorkbook(ExcelLayout.java:75)
的方法「openWorkbook」看起來像這樣:
private void openWorkbook() throws IOException {
File excelFile = new File(fileName);
timestamp = excelFile.lastModified();
// open excel file
if (fileName.endsWith(".xlsx")) {
InputStream excelStream = new BufferedInputStream(new FileInputStream(excelFile));
this.workbook = new XSSFWorkbook((excelStream));
} else {
this.workbook = new HSSFWorkbook(new POIFSFileSystem(new FileInputStream(excelFile)));
}
}
如果我在調試模式下執行所有操作,一切都會順利進行,並且不會出現錯誤消息。我沒有任何解釋這種行爲,也沒有任何想法如何解決這個問題。 任何人都可以幫忙嗎?
什麼版本Java?您可能需要查看'File.java'源文件。 – noahlz
你有'null''fileName'。 –
'fileName'在哪裏初始化? –