I'm trying to add all objects within a file to an ArrayList using an ObjectInputStream and Iterator. This is being used to deserialize all objects in a file at once into an arraylist and then add the contents of an arraylist to a tree. No matter what I try I keep getting TypeCast exceptions, StreamCorrupt exceptions, and endless while loops.

I'm having no issues actually deserializing anything and adding it to the tree. Just trying to repeat the process if the branch contains > 1 element.

writeObject is invoked upon instantiation of any object. The object calls the save_object method

I know logically what I'm supposed to be doing to get this working but nothing I try works. Can someone tell me what needs to be done to get this working?

Liberty has never come from the government.
Liberty has always come from the subjects of government.
The history of liberty is the history of resistance.
The history of liberty is a history of the limitation of governmental power, not the increase of it.