I'm trying to do an app on Java in which I need to save ArrayLists on a file. I was looking for how to do this and I found the next code:
ArrayList<Expediente> al = new ArrayList<Expediente>();
Expediente exp = new Expediente("Expediente data");
try{
    File file = new File("Pathname");
    FileOutputStream ofs = new FileOutputStream(file);
    ObjectOutputStream oos = new ObjectOutputStream(ofs);
    oos.writeObject(al);
    oos.close();
    ofs.close();
} catch (IOException e) {
    System.err.println("Error!");
    e.printStackTrace();
}
My problem now is that if I want to save the same ArrayList but with another data or if I reopen the file, the first data that is in the file is overwritten.
Could someone tell how to append this new data on the file?
Thank you.
 
     
    