Apache commons config: Generate configuration file from defaults

I want to distribute my application in one jar. That means that I do not want to ship any external files with it, that also includes that I do not want to ship the default configuration file with my project.

I could for sure build the basic XML structure with a implementation of JDOM2 or copy it out of the classpath onto the file system, but is there a out-of-the-box variant implemented by Commons Configuration?

I have only found online documentation that explains reading and handling already existing configuration files.

I would imagine this code taking in a number of Key -> Value Pairs and then generating a new config, is this possible?

Please do not offer me any alternatives to a XML file, please answer this question specifically to the implementation I asked about. If you know about any, you can suggest a alternative to Commons Configuration that does what I need to do.


What about, e.g.?

XMLConfiguration config = new XMLConfiguration();
config.addProperty("test.dir[@name]", "C:\\Temp\\");
config.addProperty("test.dir[@name]", "D:\\Data\\");

See all known implementing classes of:

And for an example.


 ? Dynamic log file path in mule
 ? Dynamic log file path in mule
 ? Dynamic log file path in mule
 ? Passing log level dynamically in log4j2.xml in Mule ESB
 ? Mule: intercepting any kind of logging and adding messages to a list
 ? How to use mule requester for SFTP - Dynamic file name and path
 ? Change logging in the Mule
 ? Custom log file name in mule using log4j
 ? How do I change the default location for mule application log files?
 ? Mule log is not working if i use synch and asyn in same log4 file