Programming - Beans serialisation to/from XML

If the Beans interface is implemented, then the classes can be serialised to/from XML using:

There may be downsides to XMLEncoder/Decoder? the documentation seems to suggest that it clones all the data which suggests there may be memory size and performance issues.


XMLDecoder d = new XMLDecoder(new BufferedInputStream(new FileInputStream("Test.xml")));
Object result = d.readObject();


XMLEncoder e = new XMLEncoder(new BufferedOutputStream(new FileOutputStream("Test.xml")));
e.writeObject(new JButton("Hello, world"));

metadata block
see also:


Correspondence about this page

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2023 Martin John Baker - All rights reserved - privacy policy.