Showing posts with label deserialization in java. Show all posts
Showing posts with label deserialization in java. Show all posts

java.lang.ClassCastException During Deserialization in java


At time of deserialization by below code
FileInputStream out= new FileInputStream("c://ser//ser.txt");
ObjectInputStream outs= new ObjectInputStream(out);
      Employee e=(employee)outs.readObject();
If JVM unable to identify the class type i.e. when outs try to call method readObject and programmer given wrong class reference then it will throw  exception

java.lang.ClassCastException: Serlialization.employee1