我有一组具有属性的对象。我想使用XStream将其序列化为XML和文件。
我有以下代码:
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"));
但是,当我运行此代码时,对getobject()
的调用会获取一个具有属性的对象,但是被吐出的xml是一行<list/>
我做错了什么?
xstream.toXML(abstractStrategy.Components.get(0).IPAddress, outputStream);