其他分享
首页 > 其他分享> > ArrayList集合到文件

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();

}

}

 

标签:文件,java,ArrayList,bw,new,集合,import,array
来源: https://www.cnblogs.com/lps1944900433/p/16060019.html