문제

I would like to be able to set the indentation to a number of spaces when storing with XStream. I have seen this SO post and I'm afraid it's not quite clear how to set the number of spaces to use. I seem to not be getting something. Could somebody kindly explain this and illustrate it with an example?

도움이 되었습니까?

해결책

Following the example in the post you've linked to and the API, I came up with this code:

char[] indent = new char[] { ' ', ' ', ' ', ' ' };
BufferedOutputStream stdout = new BufferedOutputStream(System.out);
xstream.marshal(object, new PrettyPrintWriter(new OutputStreamWriter(stdout), indent));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top