[Java] 纯文本查看 复制代码 public static void main(String[] args) throws IOException {
ArrayList<String> list = new ArrayList<String>();
list.add("hello");
list.add("world");
list.add("java");
File f=new File("a.txt");
f.createNewFile();
System.out.println(f.exists());
BufferedWriter bw = new BufferedWriter(new FileWriter("a.txt"));
for (String s : list) {
bw.write(s);
bw.newLine();
}
bw.flush();//清空缓冲区,把流压入文件
bw.close();//关闭流
System.out.println("数组写到记事本完毕!");
} |