Check out example codes for "java write arraylist of objects to file". It will help you in understanding the concepts better.

Code Example 1

try {
    FileOutputStream fos = new FileOutputStream("output");
    ObjectOutputStream oos = new ObjectOutputStream(fos);   
    oos.writeObject(MenuArray); // write MenuArray to ObjectOutputStream
    oos.close(); 
} catch(Exception ex) {
    ex.printStackTrace();
}

Learn ReactJs, React Native from akashmittal.com