Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 给定一个配置对象,如何创建PropertiesConfiguration对象?_Java_Configuration_Properties File_Apache Commons Config - Fatal编程技术网

Java 给定一个配置对象,如何创建PropertiesConfiguration对象?

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

我有一个返回配置对象的方法。我需要实例化一个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();

阅读这里的“保存”部分:谢谢-我已经读过了,但是我的配置对象实际上是一个组合配置,没有保存方法。我需要将其“转换”到属性配置,并将其保存为属性文件。