I am trying to deserialze some file in java using ObjectInputStream. I am able to read all the objects successfully but getting the EOFException. Couldn't able to find the way to check for EOFException. Tried below code. Any suggestions are appreciated.
Thanks for the help
List<Destination> destinationList = new ArrayList<Destionation>();
try(ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileName))) {
Destination destination = null;
while(true) {
destination = (Destination) in.readObject();
if(destination == null)
break;
destinationList.add(destination);
}
// Some code here
} catch (Exception e) {
e.printStackTrace();
}
**Note :- ** I only have the serialzed file.