如何setProperty并存储属性文件而不更改其他文件

时间:2013-11-25 02:19:20

标签: java file properties io

我有一个像

这样的属性文件
    #message
    message.acountcv=
    message.applipromotion=       
    #alert
    alert.auto.to.manual=
    alert.csv.download=
    .....

我希望更改属性但订单和格式已更改

Properties tmp = new Properties() {
            @Override
            public synchronized Enumeration<Object> keys() {
                return Collections.enumeration(new TreeSet<Object>(super.keySet()));
            }
        };

      Properties props = new Properties();
      myfis = new FileInputStream("/home/www/data/myproperties.properties");
      props.load(myfis);
      fos = new FileOutputStream("/home/www/data/myproperties.properties");

          props.setProperty("field.target", "123456");
            tmp.putAll(props);
            tmp.store(fos, null);
      fos.close();
      fis.close();
谁可以帮助我? 谢谢!

0 个答案:

没有答案