How to merge two java.util.Properties objects?

后端 未结 5 1467
一整个雨季
一整个雨季 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 03:51

    Assuming you eventually would like to read the properties from a file, I'd go for loading both files in the same properties object like:

    Properties properties = new Properties();
    properties.load(getClass().getResourceAsStream("default.properties"));
    properties.load(getClass().getResourceAsStream("custom.properties"));
    

提交回复
热议问题