Reputation: 225
I'm using the Apache Commons Configuration. How can I get directly a String of the XMLConfiguration without saving it to a file?
Thank you very much.
Upvotes: 3
Views: 2617
Reputation: 225
I've found the solution, it is possible via the StringWriter:
XMLConfiguration config = new XMLConfiguration();
StringWriter stringWriter = new StringWriter();
config.save(stringWriter);
System.out.println(stringWriter.toString());
Upvotes: 5
Reputation: 66723
org.apache.commons.configuration.ConfigurationUtils.toString()
public static String toString(Configuration configuration)
Get a string representation of the key/value mappings of a configuration. Parameters: configuration - the configuration Returns: a string representation of the configuration
Upvotes: 1