PropertiesProxy pp = new PropertiesProxy("custom/"); 这个可以获取 但是貌似没有写入的方法,只看到一个print,传入的是writer,这个我试了下结果貌似没啥效果。
4 回复
貌似是这样才行
public static void main(String[] args) {
FileWriter writer = null;
Map<String,Object> map = new HashMap<String,Object>();
map.put("db.url", "123");
map.put("db.username", "jdbc:oracle:456");
map.put("db.password", "789");
map.put("db.validationQuery", "select 1 from dual");
map.put("db.maxActive", "100");
String fileName = "d:/custom/db.properties";
PropertiesProxy propertiesProxy = new PropertiesProxy();
propertiesProxy.putAll(map);
try {
writer = new FileWriter(fileName);
propertiesProxy.print(writer);
} catch (IOException e1) {
e1.printStackTrace();
}finally{
if (writer != null)
try {
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
貌似这样才可以
添加回复
请先登陆