How to know whether we have reached eof while using ObjectInputStream to read a bunch of objects stored in a file.
i have a file named india.txt which contains three objects(Junk) stored using ObjectOutputStream, Now i am reading those objects using the following code snippet
objectIn = new ObjectInputStream(new BufferedInputStream(
fin = new FileInputStream("c:/Files/india.txt")));
while (true) { // this is not correct. how to check whether we reached end of file
object = (Junk) objectIn.readObject(); //may throw EOFException if the file pointer is beyond EOF
}
Thanks in advance