當我更新屬性文件時,註釋也會沿着數據更新。有任何可能的方式來刪除註釋或更新數據而無需評論。移除屬性文件中的註釋文件java
在這裏,我更新文件4次每次日期 - 時間戳附加作爲註釋
#Thu May 19 17:53:42 GMT+05:30 2011
Key_1=DSA_1024
#Thu May 19 17:53:43 GMT+05:30 2011
Key_2=DSA_1024
#Thu May 19 17:53:43 GMT+05:30 2011
Key_3=DSA_1024
#Thu May 19 17:53:44 GMT+05:30 2011
Key_4=DSA_1024
代碼
Properties prop=new Properties();
String currentDirectary=System.getProperty("user.dir");
String path=currentDirectary+"/Resource/Key.Properties";
FileOutputStream out=new FileOutputStream(path,true);
prop.setProperty("keyName","DSA_1024");
prop.store(out, null);
誰添加了這些評論?你使用什麼工具。 – Bozho 2011-05-19 12:34:08
向我們展示一些* update *屬性文件的代碼行 – 2011-05-19 12:35:33
它看起來像您使用'Properties.store()'** **追加**到一個現有的文件,這不是它應該如何使用。您應該將所有需要的屬性添加到** one **'Properties'對象,並在該*上調用'store()'一次*。 – 2011-05-19 12:35:58