I have a method that returns a Configuration object. I need to instantiate a PropertiesConfig object to save this to disk. How can I do so?
-
Read the "saving" section here: commons.apache.org/proper/commons-configuration/…Nir Alfasi– Nir Alfasi2013-08-06 01:04:47 +00:00Commented Aug 6, 2013 at 1:04
-
Thanks - I've read that, but the Config object I have is actually a CombinedConfiguration, and has no save method. I need to 'converet' it to a properties config and save it as a properties file.rjurney– rjurney2013-08-06 23:50:04 +00:00Commented Aug 6, 2013 at 23:50
Add a comment
|
1 Answer
Have you tried using copy method? This example works for me:
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();