Pim*_*m_D 2 java eclipse jar embedded-resource nosuchfileexception
当我在Eclipse中编译并运行我的程序时,运行没有异常.但是当我将它导出到可运行的jar或普通jar时,它找不到我的设置文件.
我的道路是:
String path= "src/settings/settings.ini";
Run Code Online (Sandbox Code Playgroud)
在eclipse中它运行无例外,但在jar中,它会立即抛出异常.
怎么可能让jar像日食一样工作?
在jar内部,文件不再是物理文件,因此您可能需要将其作为Stream读取
getClassLoader().getResourceAsStream("settings/settings.ini");
Run Code Online (Sandbox Code Playgroud)
考虑到settings.ini位于指定路径的classpath(运行时)下
| 归档时间: |
|
| 查看次数: |
711 次 |
| 最近记录: |