@Test
public void testWithPropertiesFile() throws Exception {
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
FileSystemResource pathResource = new FileSystemResource("test.properties");
File file = pathResource.getFile();
if (!file.exists()) {
file.createNewFile();
}
System.out.println("pathResource:" + pathResource.getPath());
System.out.println("pathResource:" + pathResource.getFile());
pfb.setLocation(pathResource);
pfb.afterPropertiesSet();
Properties props = (Properties) pfb.getObject();
System.out.println(props.get("a"));
props.setProperty("a", "DDD");
System.out.println(props.get("a"));
FileOutputStream oFile = new FileOutputStream(pathResource.getFile());
props.store(oFile, "Comment");
oFile.close();
file.deleteOnExit();
}
TestProperty.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:spring-cloud-config-support
作者:
评论列表
文章目录