I am researching way to "reading appended objects from file in java".
but my code just reading first object from file and application cannot read remainder objects from file and in this time EXCEPTION occurred.
Please represent me the useful algorithm for reading ALL appended objects from file.
The exception occurred when cal of method read():
in WHILE loop,always first object downcast to MyObject(Contact) and name,family & number of this contact, print in command line. but always when application try to downcast next objects to Contact, IOException occurred.
You shouldn't call readObject() in a loop. As far as I know it always reads the whole file in one go and then processes it and the only way to append objects is as described on the page that I linked to above. Then again, if you really want to add multiple objects to the file, why not just serialise a collection of objects instead?
As for the exception, you'll need to provide more details. There are lots of places that could throw IOExceptions in this code. Do you have the actual exception message and stacktrace?