出于某种原因(Java 新手),当我尝试从我的资源文件夹中读取 Excel 文件时,它显示它在那里,但是当我使用 FileInputStream 读取它时,我得到一个 FileNotFound 异常。有任何想法吗?
代码:
public static void openExcelSheet() throws IOException {
FileInputStream fileInputStream = null;
if(applicationSettings.class.getResourceAsStream("/files/Employees.xlsx") != null) {
System.out.println("File Found");
fileInputStream = new FileInputStream("/files/Employees.xlsx");
}else {
System.out.println("File Not Found");
}
XSSFWorkbook workbook = new XSSFWorkbook(fileInputStream);
//int numberOfSheets = workbook.getNumberOfSheets();
System.out.println(workbook.getAllNames());
workbook.close();
}
繁华开满天机
慕桂英3389331
呼啦一阵风
相关分类