How to merge two java.util.Properties objects?

后端 未结 5 1461
一整个雨季
一整个雨季 2020-12-13 03:33

I\'m trying to have a default java.util.Properties object in my class, with the default properties it accepts, and let the developer override some of them by sp

5条回答
  •  抹茶落季
    2020-12-13 04:17

    putAll(): Copies all of the mappings from the specified map to this hashtable. These mappings will replace any mappings that this hashtable had for any of the keys currently in the specified map.

    Properties merged = new Properties();
    merged.putAll(properties1);
    merged.putAll(properties2);
    

    Line 2 has no effect at all. None of the properties from the first file will be in the merged properties object.

提交回复
热议问题