import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class BufferedWriterDemo {
public static void main(String[] args) {
try {
BufferedWriter out = new BufferedWriter(new FileWriter("bwriter"));
out.write("You are my sunshine!");
out.close();
System.out.println("文件创建成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
}
执行代码,生成文件
运行结果