gpt4 book ai didi

Java:搜索配置文件:Linux 与 Windows

转载 作者:行者123 更新时间:2023-12-01 14:33:50 25 4
gpt4 key购买 nike

对于我正在构建的小型实用程序,我需要读取 config/ini 文件。这本身没有问题,但我试图找出如何在 Linux 和 Windows 上正确/最好地执行此操作。

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

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

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

有人知道有一个组件可以在公共(public)文件位置搜索我可以在代码中重用的配置/ini 文件吗?

非常感谢

最佳答案

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

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

看看

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

关于Java:搜索配置文件:Linux 与 Windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16645102/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com