【问题标题】:Java: searching for config files: linux vs windowsJava:搜索配置文件:linux vs windows
【发布时间】:2013-05-14 18:00:28
【问题描述】:

对于我正在构建的小型实用程序,我需要读取 config/ini 文件。这本身没有问题,但我试图弄清楚如何在 Linux 和 Windows 上正确/最好地做到这一点。

在 Linux 下,这个文件的位置可能是:

- /etc
- the install directory of the jars/files

在 Windows 下,我不知道 /etc 的等价物是什么(抱歉,我的所有工作都是在 Linux 上完成的)。

有没有人知道一个组件,它会搜索我可以在我的代码中重用的 config/ini 文件的公共文件位置?

非常感谢 回复

【问题讨论】:

    标签: java configuration configuration-files


    【解决方案1】:

    您可以使用系统属性来做到这一点。

    String basepath = System.getProperty("user.dir");
    

    看看

    http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html

    【讨论】:

    • 感谢您快速而直接的回答。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-13
    • 1970-01-01
    • 1970-01-01
    • 2016-07-25
    • 1970-01-01
    相关资源
    最近更新 更多