Serialization to XML

We will show here a method to serialize an instance of a class to an XML file. We will use the java.beans package and contained there classes XMLEncoder and XMLDecoder.
First we need a class to serialize:

public class SerializeMe {
public Integer data;

public void setData(Integer data) {
[...]

What are writeObject and readObject? Customizing the serialization process

Using Serialization in Java is pretty simple. If you have some object you would like to serialize, you just make it implement the Serializable interface. Then, you can use the ObjectOutputStream to store that object to a file or send it to some other machine. All non-transient and non-static fields will be serialized and even [...]

What is serialVersionUID?

Most people learn about serialVersionUID after they write their first serializable object (I know I did). You add ‘implements Serializable’ and in the next moment your IDE starts complaining… so what’s up?
Lets look at a simple example to see what meaning that variable has. In the example we will use the class SerializeMe shown below:

class [...]