MainClass.class.getResource("/Resources/file.extension")を使用してリソースを呼び出してFileのコンストラクターに渡すことにより、Javaアプリケーションでリソースを開こうとしていますgetPath()。次に、新しいものをで初期化するFileInputStreamとFile、が得られますFileNotFoundException。完全なスタックトレースは次のようになります。
java.io.FileNotFoundException: E:\user\Documents\NetBeansProjects\Project name\build\classes\Resources\file.csv (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at my.secret.project.MainClass.main(MainClass.java:27)
これが私のコードです。
File file = new File(MainClass.class.getResource("/Resources/file.extension").getPath());
...
InputStream in = new FileInputStream(file);