I have a list which I save by the following:
public void saveList(ArrayUnsortedList<Wrestler> listOfWrestlersToSave) { System.out.println(listOfWrestlersToSave); try{ ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(FILENAME)); out.close(); } catch(Exception e){ System.out.println("Couldnt save"); } }
But I want to load this saved list on start of the program so I tried this:
Additional details:public SList loadList(String fileName){ SList loadedListOfWrestlers = new SArrayIndexedList(); try{ ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileName)); loadedListOfWrestlers = (SList)in.readObject(); System.out.println(loadedListOfWrestlers); } catch(Exception e){ System.out.println(e); } return loadedListOfWrestlers; }
SList is a list (an abstract data type) which is an unsorted array that implements Serializable.
fileName is a string containing the name of the .dat file in which my saveList() method saved the list to.
But when I run loadlist() I get java.io.EOFException. I know few details are provided here, but I feel like if I provide all the details it'd be too much. So, in general, what could potentially be wrong in my load function that causes me to get java.io.EOFException?


LinkBack URL
About LinkBacks
Reply With Quote