package it.BufferedWriterDemo;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
public class Demo04 {
public static void main(String[] args) throws IOException {
ArrayList<String> al=new ArrayList<String>();
al.add("hello");
al.add("world");
al.add("java");
al.add("hi");
Object[] str=al.toArray();
BufferedWriter bw=new BufferedWriter(new FileWriter("a.tex"));
for (Object obj : str) {
bw.write((String)obj);
bw.newLine();
bw.flush();
}
bw.close();
}
}
|
|