I can serialize ArrayList for the first run. It stores the customers arraylist at the first time when the data.ser
file is created. The other times it doesn't append new ArrayList of customers.
public void serializeBank(ArrayList<Customer> newCustomers) {
try (ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("data.ser", true))) {
os.writeObject(newCustomers);
} catch (IOException i) {
i.getMessage();
}
}
Or, do i have to add new customers to the array list of existing customer and pass that updated arraylist to the serialization method? While rewriting a new file everytime a new customer is added works, I want to know if there is a way to append new customers to the existing file.