How to move elements of Java ArrayList to file in java [closed]

Make your class implement Serializable.

Open an ObjectOutputStream wrapping a FileOutputStream

write the entire List with writeObject()

close the ObjectOutputStream.

Leave a Comment