Serializing every object and its properties in a collection to XML
I have a collection of objects, with properties. I want to use XStream to serialize it to XML and in a file.
I have the following code:
XStream xstream = new XStream();
abstractStrategy.GetObject();
String Path = "C:\\Objects.xml";
File file = new File(Path);
OutputStream outputStream = new FileOutputStream(file);
OutputStreamWriter writer = new OutputStreamWriter(outputStream, Charset.forName("UTF-8"));
However, when I run this code, the cal开发者_运维问答l to getobject()
gets an object with properties, but the xml that is spitted out is one line with <list/>
What am I doing wrong?
xstream.toXML(abstractStrategy.Components.get(0).IPAddress, outputStream);
精彩评论