Saving Java Object Graphs as XML file

前端 未结 15 2561
耶瑟儿~
耶瑟儿~ 2021-02-07 12:13

What\'s the simplest-to-use techonlogy available to save an arbitrary Java object graph as an XML file (and to be able to rehydrate the objects later)?

15条回答
  •  渐次进展
    2021-02-07 12:55

    The easiest way here is to serialize the object graph. Java 1.4 has built in support for serialization as XML.

    A solution I have used successfully is XStream (http://x-stream.github.io/)- it's a small library that will easily allow you to serialize and deserialize to and from XML.

    The downside is you can only very limited define the resulting XML; which might not be neccessary in your case.

提交回复
热议问题