Loading
Serialization

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  What is Serialization ?


  • Serialization
    Sample Img 37

Ans)

Serialization is the process of converting a set of object instances that contain references to each other into a linear stream of bytes,
which can then be sent through a socket, stored to a file, or simply manipulated as a stream of data. Serialization is the mechanism used by
Objects would be passed between JVMs, either as arguments in a method invocation from a client to a server or as return values from a method invocation.

The object which is to be serialzed should implement "Serializable" interface.

 class PersonDetails implements Serializable
 
We use ObjectOutputStream to Serialize the Objects,  please take a look at colored code snippet below.

   FileOutputStream fos = null;
  ObjectOutputStream out = null;
  try {
   fos = new FileOutputStream(filename);
   out = new ObjectOutputStream(fos);
   out.writeObject(list);
   out.close();
   System.out.println("Object Persisted");
  } catch (IOException ex) {
   ex.printStackTrace();
  }



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

Serialization


Serialization

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free