关于java.util.Properties???????????
要修改某个配置文件(把table.created项目值变为true),用如下函数
protected boolean setProperties(String file)
{
Properties Props = new Properties();
try
{
FileOutputStream fis = new FileOutputStream(file);
Props.setProperty("table.created","true");
Props.store(fis,"Votes.properties");
fis.close();
}
catch(IOException ex)
{
ex.printStackTrace();
return false;
}
return true;
}
运行上述函数后发现table.created的值的确变成true了,问题是整个文件被重写了,原来除table.created外的其他项目及它们的值全部没有了。
有没有办法只改变配置文件Votes.properties中一个项目的值而其他项目都不变???(把其他项目都先读出来再写进去的方法除外)