Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ObjectInputStream EOF test

807598Aug 11 2006 — edited Jun 20 2007
I have the following code to read from .ser file.
File file = new File("/home/dhans/travelcache/test.ser");
ObjectInputStream is = new ObjectInputStream(
     new BufferedInputStream(new FileInputStream(file)));
and i am reading from the input stream by
is.readObject();
my question is how to find out whether end of file is reached using
ObjectInputStream.i tried with something like the following
while(is.readObject() != null) {
 // do something
}
but no use it is throwing java.io.EOFException if EOF is reached.
Is there a method/way to test whether end of file is reached.
any help would be helpful
tia,
dhanasekaran
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 18 2007
Added on Aug 11 2006
3 comments
1,221 views