The task is to store different objects of classes in a physically located file on hard disk. For this to store objects and their states (including the values of their data members) we have to make those classes serializeable. Use Standard Java I/O streams FileOutputStream, ObjectOutputStream to write/store to file and FileInputStream, ObjectInputStream streams to read objects from the file. After reading all objects from the file, have to type caste to their original class type and then get data from these casted objects.

Following is the code that you can see and can also download. MyObjects.java

Continue Reading…