I have saved an arrayList into a binary file by using serialastion. How do I now retrieve this data from the binary file?
This is the code I have used for serialisation
public void createSerialisable() throws IOException
{
FileOutputStream fileOut = new FileOutputStream("theBkup.ser");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(allDeps);
options();
}
and this the code I am trying to use for deserialization of the arrayList:
public void readInSerialisable() throws IOException
{
FileInputStream fileIn = new FileInputStream("theBKup.ser");
ObjectInputStream in = new ObjectInputStream(fileIn);
try
{
ArrayList readob = (ArrayList)oi.readObject();
allDeps = (ArrayList) in.readObject();
}
catch (IOException exc)
{
System.out.println("didnt work");
}
}
allDeps is the declared array list in the classes constructer. Im trying to save the arrayList from the file to the arrayList declared in this class.