Search code examples
javaxmlapache-commons-config

XMLConfiguration to String


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.


Solution

  • 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());