Deserializing an Object to a File

PHOTO EMBED

Sun Dec 25 2022 15:02:45 GMT+0000 (Coordinated Universal Time)

Saved by @prettyleka #java

public class Person implements Serializable {
  public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
 
    FileInputStream fileInputStream = new FileInputStream("persons.txt");
    ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
 
    Person michaelCopy = (Person) objectInputStream.readObject();
    Person peterCopy = (Person) objectInputStream.readObject();
  }
}
content_copyCOPY