首页 > 代码库 > IO流入门-第八章-BufferedWriter

IO流入门-第八章-BufferedWriter

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();
    }
}

 

IO流入门-第八章-BufferedWriter