|
Java™ by example!
|
|
|
How do I serialize a Java object into XML?
Representing a complex object graph into an XML is not easy and binary serialization happens much faster. If you still need to represent your Java objects in XML, you can use the package JSX, downloadable from http://www.freshmeat.net/projects/jsx. Put JSX0.9.5.0.jar in your classpath and try out the following example. Customer.java:
MainOut.java:
MainIn.java:
If you execute java MainOut, the following XML will be written to disk. test.xml:
MainIn will read in test.xml and create a Customer object from it.
Further Information
Author of answer: Joris Van den Bogaert
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|