Serialization In Java

Serialization In Java -
 In java, serialization is the process for writing the state of object in sequence
 of bytes stream. Serialization process for an object also called marshalling.

 How to serialize an object?
     Serializble is a marker interface, Through the implimantaion of Serializble interface
 any object can be serialize.

 There is no methods in Serializble interface, but Serializble interface tell to JVM
 that Object can be written in byte stream.

 If Serialized object have any transient variable. It means transient variable will not
 written in to byte stream.

 Example of Serialization -

 class A implements Serializable{
    A(String personName, Integer age){
    private String personName = null;
    private transient Integer age = null;
    public Integer getAge() {
        return age;
    public String getPersonName() {
        return personName;

public class Test {
    public static void main(String[] args) {
            A a = new A("Alber", new Integer(50));
            ObjectOutputStream ObjOut = new ObjectOutputStream(new FileOutputStream("test.txt"));
        }catch(IOException e){

Popular posts from this blog

What is NBioBSP Java Library?

Draw arrow line example

Capture image from webcam java code, examples