gpt4 book ai didi

java - 给定一个 Configuration 对象,如何创建 PropertiesConfiguration 对象?

转载 作者:行者123 更新时间:2023-11-30 04:17:13 26 4
gpt4 key购买 nike

我有一个返回配置对象的方法。我需要实例化一个 PropertiesConfig 对象以将其保存到磁盘。我怎样才能这样做?

最佳答案

您尝试过使用复制方法吗?这个例子对我有用:

    XMLConfiguration conf1 = new XMLConfiguration("table1.xml");
XMLConfiguration conf2 = new XMLConfiguration("table2.xml");

// Create and initialize the node combiner
NodeCombiner combiner = new UnionCombiner();
combiner.addListNode("table"); // mark table as list node
// this is needed only if there are ambiguities

// Construct the combined configuration
CombinedConfiguration cc = new CombinedConfiguration(combiner);
cc.addConfiguration(conf1, "tab1");
cc.addConfiguration(conf2);

PropertiesConfiguration config = new PropertiesConfiguration("usergui.properties");

config.copy(cc);
config.save();

关于java - 给定一个 Configuration 对象,如何创建 PropertiesConfiguration 对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18070132/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com