|
JSX 2.2.7.1 (Monday 9 February 2009)
This release fixes a problem with java.util.Calendar's latest version being unable to read XML serialized from JDK1.3
download trial version of JSX jar (94668 bytes)
XML Schema for JSX: jsx.xsd
Please email technical questions to the mailing list
JSX works with Java 1.2, 1.3, 1.4, 1.5 and 1.6
Please post bug reports to the mailing list (please
include complete stack traces, XML and code so that the problem can be
reproduced) bug report
Mailing list
archives
Command line test
Cut and paste this "export" test to the command line:
java -classpath JSX2.2.7.1.jar JSX.ObjectWriter > test.xml
Which generates XML something like this:
test.xml (or try this test.xml.txt for some browsers)
"Import" by cutting and pasting this to the command line:
java -classpath JSX2.2.7.1.jar JSX.ObjectReader < test.xml
or, instead of redirecting standatd input, use an explicit filename:
java -classpath JSX2.2.7.1.jar JSX.ObjectReader test.xml
Edit "test.xml" by hand and import it again - thus, you can process object data
independently of the objects themselves.
Get started
Write out an object:
new JSX.ObjectWriter(new FileWriter("my.xml")).writeObject(yourObject);
Note: with older versions of JSX2, you need to explicitly close the stream (or you'll get an EOFException when reading):
JSX.ObjectWriter out = new JSX.ObjectWriter(new FileWriter("my.xml"));
out.writeObject(yourObject);
out.close();
Read it in again:
Object obj = new JSX.ObjectReader(new FileReader("my.xml")).readObject();
Note: in all these examples, you can omit the Writer and Reader argument to the
constructor, and JSX will default to System.out and System.in for convenience
when testing. They also accept OutputStreams and InputStreams.
Switch to JSX
To switch from Java's binary serialization to JSX, you only need to
replace its constructor with JSX. JSX is a drop-in replacement for
standard Java serialization, so nothing else needs to be changed
- only the constructor.
For example, change your code from this...
ObjectOutputStream out = new ObjectOutputStream(myout);
...to this:
ObjectOutputStream out = new JSX.ObjectWriter(myout);
Do the same for any ObjectInputStream constructors, and that's it! There's
nothing else to do!
|