我正在使用 Apache Commons 配置。如何在不将其保存到文件的情况下直接获取 XMLConfiguration 的字符串?
非常感谢。
最佳答案
我找到了解决方案,可以通过 StringWriter 实现:
XMLConfiguration config = new XMLConfiguration();
StringWriter stringWriter = new StringWriter();
config.save(stringWriter);
System.out.println(stringWriter.toString());
关于java - XML配置到字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5928504/