簡體   English   中英

讀取xlsx文件時出現FileNotFoundException

[英]FileNotFoundException while reading a xlsx file

我正在嘗試使用以下代碼從項目文件夾中讀取.xlsx文件,但它始終會拋出FileNotFoundException 我已經附上了文件所在的項目結構。

public static void main(String[] args)  {
    try {
        String excelFilePath = "‪DataModel.xlsx";
        File file = new File(excelFilePath);
        FileInputStream fis = new FileInputStream(file);         

    } catch (Exception ex) {
        System.out.print(ex);
    }
}

在此處輸入圖片說明

這是我通常的處理方式:

File file = new File( javaApplication2.class.getResource( excelFilePath ).getPath() );

classLoader.getResource()解決了問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM