Properties其实就是java的一个对象,他可以通过读取配置文件的方式来获取文件的内容。
1:java代码示例
@Test
public void ptest(){
Properties properties = new Properties();
try (FileInputStream fis = new FileInputStream("D://service.properties")) {
properties.load(fis);
} catch (IOException e) {
throw new RuntimeException("flyusercenter加载配置失败", e);
}
String test = properties.getProperty("test");
System.out.println(test);
String ALIAS = properties.getProperty("ALIAS");
System.out.println(ALIAS);
}
2:service.properties文件示例
ALIAS=dishui
test=test