XMLConfiguration for string

I am using Apache Commons configuration. How can I get the XMLConfiguration line directly without saving it to a file?

Many thanks.

+3
source share
2 answers

I found a solution, this is possible through StringWriter:

XMLConfiguration config = new XMLConfiguration();
StringWriter stringWriter = new StringWriter();
config.save(stringWriter);
System.out.println(stringWriter.toString());
+5
source

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
+1
source

All Articles