IO流入门-第八章-BufferedWriter

时间:2022-11-11 06:16:43

BufferedWriter基本用法和方法示例

import java.io.*;

public class BufferedWriterTest01
{
public static void main(String[] args) throws Exception
{
//创建带有缓冲区的字符输出流
//BufferedWriter bw = new BufferedWriter(new FileWriter("temp04")); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("temp04",true))); bw.write("hello");
bw.newLine(); //写入一个行分隔符
bw.write("java"); bw.flush(); bw.close();
}
}