【问题标题】:How to indent XML with XStream?如何使用 XStream 缩进 XML?
【发布时间】:2014-02-19 11:22:51
【问题描述】:

我希望能够在使用 XStream 存储时将缩进设置为多个空格。我见过this SO post,恐怕不太清楚如何设置要使用的空格数。我似乎没有得到什么。有人可以解释一下并举例说明吗?

【问题讨论】:

    标签: java xml xstream


    【解决方案1】:

    按照您链接到的帖子中的示例和API,我想出了以下代码:

    char[] indent = new char[] { ' ', ' ', ' ', ' ' };
    BufferedOutputStream stdout = new BufferedOutputStream(System.out);
    xstream.marshal(object, new PrettyPrintWriter(new OutputStreamWriter(stdout), indent));
    

    【讨论】:

      猜你喜欢
      • 2012-11-18
      • 2023-04-06
      • 2014-12-25
      • 2011-09-19
      • 1970-01-01
      • 2011-04-07
      • 2013-08-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多