What are the relative advantages of XMLEncoder and XStream?

后端 未结 8 2225
余生分开走
余生分开走 2021-02-06 13:12

Suppose I want to store many small configuration objects in XML, and I don\'t care too much about the format. The XMLDecoder class built into the JDK would work, and from what I

相关标签:
8条回答
  • 2021-02-06 13:52

    You should avoid XMLEncoder/XMLDecoder like the plague if you're going to be persisting a non-trivial number of objects or your system needs to be multithreaded. See http://matthew.mceachen.us/blog/do-not-want-xmlencoder-129.html for the grisly details.

    If you must use XML, XStream is great. But ask yourself if you really need to use XML. Here's a serialization benchmark project that might turn you on to better solutions:

    http://code.google.com/p/thrift-protobuf-compare/wiki/Benchmarking

    0 讨论(0)
  • 2021-02-06 13:53

    I always find XStream very tempting, because it's so easy to get going. However, invariably I end up replacing it. It's really quite buggy, and its collection handling could use a lot of work.

    As a result, I usually switch to JAXB. It's an awful lot more robust, it's pretty much bug-free, and a more flexible than XStream.

    0 讨论(0)
提交回复
热议问题