把集合中的数据写到文本文件中(array)

package fangfa;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
public class text {
public static void main(String[] args) throws IOException {
ArrayList array=new ArrayList();
array.add(“hello”);
array.add(“lena”);
BufferedWriter bw=new BufferedWriter(new FileWriter(“array.txt”));
for(int i=0;i String s=array.get(i);
bw.write(s);
bw.newLine();
bw.flush();
}
bw.close();
}
}

你可能感兴趣的:(代码)