Serialization

Java Serialization Tutorial

As much Java knows how to use objects, perhaps no other language knows. You can assign the properties of one object to another in three ways – Shallow copying, Deep copying and Cloning. You can imagine a simple primitive data type as an object with wrapper classes. You can see…

Marker interfaces Java

After knowing what is serialization, let us know something more. To support serialization, java.io package comes with interface Serializable and two classes ObjectOutputStream and ObjectInputStream. 1. class java.io.ObjectOutputStream Following is the class signature public class ObjectOutputStream extends OutputStream implements ObjectOutput, ObjectStreamConstants The methods of ObjectOutputStream are capable to save the…

What is Serialization in Java?

Serialization Introduction Before going into the subject, let us see some code which is very laborious and how Serialization makes it easy.

The above code perfectly compiles and runs. The aim of the code is to write the Student data to a hard disk file for a permanent storage…

Java Serialization Example

After knowing what is serialization and the classes available supporting serialization, let us write a program where a Student object is serialized, Student objects are written to a file and later read from the file. In this program, usage of access modifier "transient keyword" is illustrated (observe, the string address…