//读配置文件片段
public String getPropertyValue(String key){
Properties pro = new Properties();
try {
InputStream in = new FileInputStream(""); //加载配置文件
try {
pro.load(in);
} finally {
in.close();
}
return pro.getProperty(key);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
//写配置文件片段
public void setPropertyValue(String key, String value){
Properties pro = new Properties();
try {
InputStream in = new FileInputStream(""); //加载配置文件
try {
pro.load(in);
} finally {
in.close();
}
pro.setProperty(key, value);
OutputStream out =new FileOutputStream(""); //加载配置文件
try{
pro.store(out, "modi by lmy");
out.flush();
}finally{
out.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}