ArrayList集合到文件

package com.czie.iot1913.lps.IO.BufferStream;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

/**
* FileName: ArrayListToTxt
* Author: lps
* Date: 2022/3/26 17:15
* Sign:刘品水 Q:1944900433
*/
public class ArrayListToTxt {
public static void main(String[] args) throws IOException {
ArrayList<String> array = new ArrayList<String>();
array.add("1944900433");
array.add("15751403365");
array.add("刘品水");
//FileWriter fw = new FileWriter("F:\\JavaCode\\fw.txt");

BufferedWriter bw = new BufferedWriter(new FileWriter("F:\\JavaCode\\array.txt"));
//bw.write(String.valueOf(array));
for (String s : array) {
bw.write(s);
bw.newLine();
bw.flush();
}
bw.close();

}

}

 

posted @ 2022-03-26 17:25  刘品水  阅读(42)  评论(0编辑  收藏  举报