How to write an ArrayList of Strings into a text file?

后端 未结 7 1099
不思量自难忘°
不思量自难忘° 2020-11-27 15:47

I want to write an ArrayList into a text file.

The ArrayList is created with the code:

ArrayList arr = new A         


        
7条回答
  •  一整个雨季
    2020-11-27 16:19

    import java.io.FileWriter;
    ...
    FileWriter writer = new FileWriter("output.txt"); 
    for(String str: arr) {
      writer.write(str + System.lineSeparator());
    }
    writer.close();
    

提交回复
热议问题