Java 给定一个配置对象,如何创建PropertiesConfiguration对象?
我有一个返回配置对象的方法。我需要实例化一个PropertiesConfig对象以将其保存到磁盘。我该怎么做?您是否尝试过使用复制方法?这个例子对我很有用:Java 给定一个配置对象,如何创建PropertiesConfiguration对象?,java,configuration,properties-file,apache-commons-config,Java,Configuration,Properties File,Apache Commons Config,我有一个返回配置对象的方法。我需要实例化一个PropertiesConfig对象以将其保存到磁盘。我该怎么做?您是否尝试过使用复制方法?这个例子对我很有用: XMLConfiguration conf1 = new XMLConfiguration("table1.xml"); XMLConfiguration conf2 = new XMLConfiguration("table2.xml"); // Create and initialize the node co
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();
阅读这里的“保存”部分:谢谢-我已经读过了,但是我的配置对象实际上是一个组合配置,没有保存方法。我需要将其“转换”到属性配置,并将其保存为属性文件。