title: getting multiple objects from serialization in java
body: <p>i want to get multiple oblects of Employee class from the file using serialization. here i am getting only one object any solution??</p>
  
  <pre><code>    package com.jbt;
  
      import java.io.Serializable;
  
      public class Employee implements Serializable
      {
         public String firstName;
         public String lastName;
         private static final long serialVersionUID = 5462223600l;
      }
  
  
  
  
      package com.jbt;
  
      import java.io.FileOutputStream;
      import java.io.IOException;
      import java.io.ObjectOutputStream;
  
      public class SerializaitonClass {
  
          public static void main(String[] args) {
              Employee emp = new Employee();
              emp.firstName = "Vivekanand";
              emp.lastName = "Gautam";
  
              try {
                  FileOutputStream fileOut = new FileOutputStream("./employee.txt");
                  ObjectOutputStream out = new ObjectOutputStream(fileOut);
                  out.writeObject(emp);
                  out.close();
                  fileOut.close();
                  System.out.printf("Serialized data is saved in ./employee.txt file");
              } catch (IOException i) {
                  i.printStackTrace();
              }
          }
      }
  
  
  
  package com.jbt;
  
  import java.io.*;
  
  public class DeserializationClass {
      public static void main(String[] args) {
          Employee emp = null;
          try {
              FileInputStream fileIn = new FileInputStream("./employee.txt");
              ObjectInputStream in = new ObjectInputStream(fileIn);
              emp = (Employee) in.readObject();
              in.close();
              fileIn.close();
          } catch (IOException i) {
              i.printStackTrace();
              return;
          } catch (ClassNotFoundException c) {
              System.out.println("Employee class not found");
              c.printStackTrace();
              return;
          }
          System.out.println("Deserializing Employee...");
          System.out.println("First Name of Employee: " + emp.firstName);
          System.out.println("Last Name of Employee: " + emp.lastName);
      }
  }
  </code></pre>
  
  <p>here in Deserialization class how i can take multiple objects in List??
  thanks in advance..!!</p>