I am currently doing serialization in JAVA, As of now I have gotten the serializing and de-serializing working correctly. eg If I make a film in the program, close the program and then reopen the program the film will still be there. My problem is, even though all the code works and the serializing works correctly when I run the program I get this error as seen below.
Here you can see my program running and it showing the exception
Here is the code where the exception is pointing to
public void readRecordsFromFile()
{
Video v = null;
try
{
FileInputStream fileIn = new FileInputStream("PrintOut.dat");
ObjectInputStream in = new ObjectInputStream(fileIn);
while((v = (Video)in.readObject()) != null)
{
videos.add(v);
}
//videos=(ArrayList<Video>)in.readObject();
fileIn.close();
in.close();
}
catch(IOException i)
{
System.out.println("IO Exception");
i.printStackTrace();
return;
}
catch(ClassNotFoundException m)
{
System.out.println("Class Not Found Exception");
m.printStackTrace();
return;
}
}
And in particular it points to the line
while((v = (Video)in.readObject()) !=null)
Is there a way to remove the exception? The fact that my program runs fine even with the exception makes me believe that it maybe isn't that important but I feel it would be good practice to remove the exception.
Any help would be appreciated and if any of the other code is required just let me know, Thanks in advance, Jason