the given function writes in file but on calling again it overwrites the previous list object in file eg
if array list index 0 contain name- "aman" and i call this function it saves "aman" in file. but when for index 1 having name-"lavesh" is called it overwrites on previous data
it is in file like "lavesh" but i want it like " aman lavesh "
public void alter_file( ArrayList<Flight_registrie> x) {
try {
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(" Flight Registrie.txt"));
oos.writeObject(x);
x.clear();
oos.close();
} catch (IOException e) {
System.out.println("An I/O error occurs");
e.printStackTrace();
}
}
No error is there but my method can be wrong