Skip to main content

Posts

Showing posts with the label ObjectOutputStream

Serialization in Java with example

What is Serialization? Serialization is the process of encoding an object to byte stream and reverse of it is called deserialization.It is platform independent process which means you can serialize the object in one JVM and can transport the object over network and / or store it in filesystem and then deserialize it in other or on same JVM. Class needs to implements marker interface Serializable in order to make their object to be eligible for Serialization. fields with transient and/or static modifiers are not serialized by regular serialization process. ObjectInputStream and ObjectOutputStream are high level stream classes which have methods to serialize and de-serialize Java objects. ObjectOutputStream class has many write methods but the method that is usually used method is: public final void writeObject ( Object obj ) throws IOException ObjectInputStream class has many read methods but the method that is usually used method is: public final Object read