【发布时间】:2014-02-19 11:22:51
【问题描述】:
我希望能够在使用 XStream 存储时将缩进设置为多个空格。我见过this SO post,恐怕不太清楚如何设置要使用的空格数。我似乎没有得到什么。有人可以解释一下并举例说明吗?
【问题讨论】:
我希望能够在使用 XStream 存储时将缩进设置为多个空格。我见过this SO post,恐怕不太清楚如何设置要使用的空格数。我似乎没有得到什么。有人可以解释一下并举例说明吗?
【问题讨论】:
按照您链接到的帖子中的示例和API,我想出了以下代码:
char[] indent = new char[] { ' ', ' ', ' ', ' ' };
BufferedOutputStream stdout = new BufferedOutputStream(System.out);
xstream.marshal(object, new PrettyPrintWriter(new OutputStreamWriter(stdout), indent));
【讨论】: