Answers for "write arraylist to file java"

0

java output array lists to file

import java.io.FileWriter;
...
FileWriter writer = new FileWriter("output.txt"); 
for(String str: arr) {
  writer.write(str + System.lineSeparator());
}
writer.close();
Posted by: Guest on June-21-2020
0

java write arraylist of objects to file

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();
}
Posted by: Guest on June-06-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language