Java言語でExcelファイルを読み込む際に、対象ファイルの格納先パスを指定したところ
パス、ファイル名ともに正しいにも関わらずFileNotFoundExceptionの例外が発生しました。
ファイルがあるにもかかわらず、FileNotFoundExceptionが発生することはあるのでしょうか?
ある場合、何が原因として考えられるのでしょうか?
ご存知の方いらっしゃいましたら、ご教授ください。
お願いいたします。
public Workbook excelRead(String excelPath) { FileInputStream is =null; Workbook wb = null; try { is = new FileInputStream(excelPath); wb =WorkbookFactory.create(is); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (EncryptedDocumentException e) { e.printStackTrace(); } catch (InvalidFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally{ try { is.close(); } catch (IOException e) { e.printStackTrace(); } } return wb; } java.io.FileNotFoundException: "C:\aaa\bbb\test.xls" (ファイル名、ディレクトリ名、またはボリューム ラベルの構文が間違っています。) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(FileInputStream.java:195) at java.io.FileInputStream.<init>(FileInputStream.java:138) at java.io.FileInputStream.<init>(FileInputStream.java:93) at knowledge.ExcelOpe.excelRead(ExcelOpe.java:34) at PCkanriweekly.WeeklyCheck.main(WeeklyCheck.java:84) Exception in thread "main" java.lang.NullPointerException at knowledge.ExcelOpe.excelRead(ExcelOpe.java:47) at PCkanriweekly.WeeklyCheck.main(WeeklyCheck.java:84)
回答4件
あなたの回答
tips
プレビュー