handling EOFException in java
<p>I have created a method in my java assignment to write into a file from a <code>LinkedList</code> (I used serialization) , then I have created another method to read the file into the <code>inkedList</code>. The following is my method's body:</p>

<pre><code>try {
    FileInputStream fin = new FileInputStream("c:\\Info.ser");
    ObjectInputStream ois = new ObjectInputStream(fin);


    Employee e = (Employee) ois.readObject();
    linkP.add(e);


} catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
</code></pre>

<p>but it doesnt work right. I think this part:</p>

<pre><code>Employee e = (Employee) ois.readObject();
linkP.add(e);
</code></pre>

<p>reads only the first object of the file into the linkedlist and ignores other objects. I surrounded it for loop and while loop several times but it causes <code>EOFException</code>. How can I change my method to read all of the file's objects into the LinkedList?</p>
