原代码:
InputStream is=new FileInputStream(filename);
OutputStream os=new FileOutputStream(filename);
pps.load(is);
is.close();
pps.setProperty(key, value);
pps.store(os, "Update "+key+" "+value);
System.out.println(os.toString());
System.out.println(is.toString());
System.out.println(pps.toString());
os.close();
修改后代码:
InputStream is=new FileInputStream(filename);
pps.load(is);
is.close();
OutputStream os=new FileOutputStream(filename);
pps.setProperty(sname, value);
pps.store(os, "Update "+sname+" "+value);
System.out.println(os.toString());
System.out.println(is.toString());
System.out.println(pps.toString());
os.close();
输出流要放在 load加载 后边才可以。