//读取
private String getValue(String key,String defValue){
File config = new File(m_sConfigFile);
if (!config.exists()) {
try{
config.createNewFile(); //不存在则创建
}catch (Exception e){
}
}
Properties props = new Properties();
try{
FileInputStream is = new FileInputStream(m_sConfigFile);
props.load(is);
}catch (Exception e){
}
try {
String sValue = null;
sValue = props.getProperty(key);
if(sValue == null){
setValue(key,defValue);
return defValue;
}
return sValue;
}catch (Exception e){
}
return defValue;
}
//修改
private String setValue(String key,String value) {
File config = new File(m_sConfigFile);
if (!config.exists()) {
try{
config.createNewFile();
}catch (Exception e){
}
}
Properties props = new Properties();
Android 文件方式读取与修改配置(properties)方法
最新推荐文章于 2024-06-21 09:43:31 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)