What are the relative advantages of XMLEncoder and XStream?

后端 未结 8 2208
余生分开走
余生分开走 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:36

    If you are planning on storing all those configuration objects in a single file, and that file will be quite large, both the options you've outlined above could be quite memory intensive, as they both require the entire file to be read into memory to be deserialized.

    If memory usage is a concern (the file containing the XML will be very large), I recommend SAX.

    If memory usage is not a concern (the file containing the XML will not be very large), I'd use whatever is included with the default JRE (in this case XMLDecoder) just to remove 3rd party dependencies.

提交回复
热议问题