JavaIntermediate#serialization

What is serialization in Java?

The process of converting an object's state into a byte stream so it can be persisted to disk or sent over a network, and later reconstructed (deserialization). A class must implement Serializable to support it.

Example
class User implements Serializable {
  String name;
}
try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("user.ser"))) {
  out.writeObject(new User());
}

Related Questions

1
JavaIntermediate#serialization

What is the purpose of serialVersionUID?

Open
2
JavaIntermediate#serialization

What happens to static and transient fields during serialization?

Open
3
JavaAdvanced#serialization

How can you customize the serialization process?

Open