How to read objects from an ObjectInputStream without throwing EOFException

Hi all,

I have a program which reads objects from a file with a while loop, However, it seems that the EOFException must be caught in order to continue the program. Is it possible for me to continue the program without throwing the exception? As I know, the FileReader has a ready() method. Is there anything that is similar in the ObjectInputStream? Thank you!~~

[376 byte] By [softdev20a] at [2007-9-30 23:43:29]
# 1
Try (available()>0), but it must be supported correctly by the wrapped stream (f.i. for compressed streams it isn't). Or write some special end-of-file object to the end of your stream.
marat_khalilia at 2007-7-7 14:57:27 > top of Java-index,Core,Core APIs...
# 2
If you do a low level int ch = in.read() this returns -1 on EOF rather than EOFEception.Why not just catch the exception. It is not work to avoid the EOFEception than to just handle it.
Peter-Lawreya at 2007-7-7 14:57:27 > top of Java-index,Core,Core APIs...
# 3
Hello marat_khalili, thanks for your helpful reply~~~
softdev20a at 2007-7-7 14:57:27 > top of Java-index,Core,Core APIs...