Question

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?

Was it helpful?

Solution

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();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top