我正在使用 XStream 序列化程序来序列化一个原语并面临反序列化的问题。以下是问题描述:
说,我有:
int i = 80;
我将其序列化如下:
serializer.toXML(i, new FileOutputStream("me.xml"));
并获取此 xml:
<int>80</int>
但是当我试图解除现实时:
i = (int) serializer.fromXML("me.xml");
我得到这样的例外:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
at com.thoughtworks.xstream.core.util.FastStack.pop(FastStack.java:42)
at com.thoughtworks.xstream.io.xml.AbstractPullReader.move(AbstractPullReader.java:125)
at com.thoughtworks.xstream.io.xml.AbstractPullReader.moveDown(AbstractPullReader.java:103)
at com.thoughtworks.xstream.io.xml.XppReader.<init>(XppReader.java:63)
at com.thoughtworks.xstream.io.xml.AbstractXppDriver.createReader(AbstractXppDriver.java:54)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:912)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:903)
at Utilities.Parser.serializeTimeIntervalDuration(Parser.java:371)
at Utilities.Parser.parseData(Parser.java:152)
at CoreLayer.Main.Main.main(Main.java:52)
有人能指出我的错误吗?
提前致谢!