Reputation: 185
I would like to append Serializable objects in a existing file, but apparently it deletes the previous stored objects.
For the parameter File F, I send new File(file's path). Maybe my mistake is from there ?
Thank you for helping.
public static void wrinting(File[] tab, File f) throws Exception{
ArrayList<ImageClass> obj = imagesArray(tab);
ObjectOutputStream oos;
try {
oos = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(f)));
for (ImageClass i : obj) {
oos.writeObject(i);
}
oos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Upvotes: 0
Views: 109
Reputation: 3852
Open the FileOutputStream
like this instead:
new FileOutputStream(f, true)
Upvotes: 1