java – 加载多个属性文件

是否可以在Java中堆叠加载的属性?例如我可以做:

Properties properties = new Properties();

properties.load(new FileInputStream("file1.properties"));
properties.load(new FileInputStream("file2.properties"));

并从两个访问属性?

最佳答案
你可以这样做:

Properties properties = new Properties();

properties.load(new FileInputStream("file1.properties"));

Properties properties2 = new Properties();
properties2.load(new FileInputStream("file2.properties"));

properties.putAll(properties2);

转载注明原文:java – 加载多个属性文件 - 代码日志