java.util.Properties读取并解析配置文件
@Test
public void Properties() throws Exception {
Properties properties = new Properties();
// 使用InPutStream流读取properties文件
BufferedReader bufferedReader = new BufferedReader(new FileReader("C:\\Users\\Administrator\\Desktop\\sms\\bbb.properties"));
properties.load(bufferedReader);
// 获取key对应的value值
System.out.println("aaa="+properties.getProperty("aaa"));
System.out.println("url="+properties.getProperty("url"));
System.out.println("id="+properties.getProperty("id"));
}
bbb.properties文件内容可以是=和:格式
aaa=123
url=https://plus.migu.cn/whalecallback/delivery/pagevisit/14711?group_id=123
id=123edc
aaa:123
url:https://plus.migu.cn/whalecallback/delivery/pagevisit/14711?group_id=123
id:123edc
输出为:
aaa=123
url=https://plus.migu.cn/whalecallback/delivery/pagevisit/14711?group_id=123
id=123edc