This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Writing and reading objects
Posted by tricky on February 09, 2002 at 8:50 AM
first of all thanks to all guys involved with this board.
My question :
I have one abstract class X and several from X inherited classes a,b,c,d and e. I want to program a abstract method in X which saves and reads the data of a,b.. . I know how to make it in each class e.g by writing the data into a string and then writing in to disc. But this is not an elegant way to do the problem. I have an example in a book writing and reading ONE instance of a class by using readObject writeObject of the ObjectInputStream and ..OutputStream. But if have 5 instances of a and b in a file "info.dat" how read them all (there is a method instanceOf so I do know to which class they belong).
I would be nice if sb out there could help me