Java读取properties配置文件的方式
一.背景
二.代码片段
三.完整工具类代码
Java读取 properties 配置文件的方式,主要是通过 getProperty() 方法。config.properties 文件中有诸如 config.a = xxx 这样的存储形式,下面代码是读取 properties 配置文件中参数数据到 String 类型变量中。
readProperties 方法中的参数是<code>.properties</code>配置文件的相对路径,比如<code>src/main/resources</code>,getkey 方法用来依据键取出值
<code>.properteis</code>文件内容怎么写呢?如下: