Asa*_*aya 1 java filenotfoundexception maven
我正在使用此代码来读取 Maven 模块中的文件内容。该文件存储在一个目录中,直到工作目录。
String configFilePath = System.getProperty("user.dir") + "../conf/gce-configuration.xml";
File configFile = new File(configFilePath);
Run Code Online (Sandbox Code Playgroud)
然后当我尝试读取文件时,它给了我找不到文件错误。
找不到文件:/home/xxxx/bin../conf/gce-configuration.xml
我尝试了不同的方法,但仍然收到此错误。我在这里做错了什么?
编辑:好像我忘了在 Maven 模块中的 assembly/bin.xml 中提及文件名。所以 xml 文件不包含到包中。我的错!
当您想在当前目录之上上一级时,您可以通过
String configFilePath = new File(System.getProperty("user.dir")).getParent() + "/conf/gce-configuration.xml";
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5751 次 |
| 最近记录: |