public void abc(String value) {
String path = this.getClass().getProtectionDomain().getCodeSource()
.getLocation().getPath();
String rootPath = path.substring(0, path.lastIndexOf("/classes"));
String propertyFilePath = rootPath
+ "/classes/SysVersionConfig.properties";
Properties prop = new Properties();// 属性集合对象
FileInputStream fis;
try {
fis = new FileInputStream(propertyFilePath);// 属性文件输入流
prop.load(fis);// 将属性文件流装载到Properties对象中
fis.close();// 关闭流
// 修改sitename的属性值
prop.setProperty("smsconfig", value);
// 文件输出流
FileOutputStream fos = new FileOutputStream(propertyFilePath);
// 将Properties集合保存到流中
prop.store(fos, "Copyright (c) Boxcode Studio");
fos.close();// 关闭流
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
原文出自于:http://blog.csdn.net/cxhzqhzq/article/details/6079670
java配置文件property文件内容的修改
最新推荐文章于 2024-07-22 14:15:06 发布