如何在Java中处理配置属性

Ali*_*_IT -7 java parsing

出于我的项目的目的,我需要一个Config文件来设置一些值,我需要解析这个文件并将指定的值提取到代码中的变量.你有任何建议或我可以使用的工具吗?我用Java编写代码!

Mir*_*ari 6

利用标准Java Properties类.创建属性文件,即conf.properties加载它.

#conf.properties:
key=value

#code
Properties conf = new Properties();
conf.load(new FileInputStream(new File("conf.properties")));
conf.getProperty("key"); // returns "value"
Run Code Online (Sandbox Code Playgroud)