如何删除属性文件中的键和值?我的财产文件包含以下内容:删除属性文件中的条目
key1=value1
key2=value2
我用下面的代码删除条目key2=value2
。在此之后,现在该文件具有以下值:
key1=value1
key2=value2
Wed Mar 06 12:36:32 IST 2013
key1=value1
Java代码来删除条目:
FileOutputStream out1 = new FileOutputStream(file, true);
prop.remove(key);
prop.store(out1,null);
什么是错我做。如何在写入文件之前清除文件的全部内容。
尝试'新的FileOutputStream中(文件,* FALSE *)' – 2013-03-06 07:19:35
检查http://stackoverflow.com/questions/4225794/delete-key-and-value-from-a-property-file – Abi 2013-03-06 07:20:44
不要以追加模式打开文件。 – 2013-03-06 07:21:10