The object in the ObjectInputStream is an instance of the infrastructure
class, not an instance of the terrain
class. This will work:
(infrastructure) ois.readObject()
It is not possible to help you further without knowing more about the code which created your terrain.txt
file. Either you need documentation which tells you exactly which objects were written to that file, or you need to examine the code which wrote the file so you can know exactly which objects were written.
Side note: Java objects are not serialized as plain-text, so it is not correct to name a file containing serialized Java objects with a .txt
extension. Usually the .ser
extension is used for such files.