Write a java program which will de-Serializable from the specified file?



import ep.Emp;
import java.io.*;
class Dserp {
 public static void main(String[] args) throws Exception {
  Emp eo1 = new Emp();
  FileInputStream fis = new FileInputStream("employee");
  ObjectInputStream ois = new ObjectInputStream(fis);
  Object obj = ois.readObject();
  eo1 = (Emp) obj;
  System.out.println("EMP NO : " + eo1.getEmpno());
  System.out.println("EMP NAME : " + eo1.getEname());
  System.out.println("EMP SALARY : " + eo1.getSal());
  ois.close();
  fis.close();
 }
}

Output:

EMP NO : 100
EMP NAME : KVR
EMP SAL : 10000.0


No comments:

Post a Comment