我有一个引发此错误的应用程序(仅发生在 xlsx 文件中):
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)));
}
}
如果我在调试模式下执行所有操作,一切都会顺利进行,并且不会出现错误消息。我对这种行为没有任何解释,也不知道如何解决它。有人可以帮忙吗?