带缓冲区的输出流(写)案例

来源:互联网 发布:登陆艇升级数据 编辑:程序博客网 时间:2024/05/19 10:08
package com.hfxt;import java.io.BufferedWriter;import java.io.FileWriter;import java.io.IOException;import java.io.Writer;//用带缓冲区的字符流(写):效率更高public class BufferedWriterDemo {public static void main(String[] args) {Writer fw = null;BufferedWriter bw = null; try {fw = new FileWriter("F:/fangchen/test.txt");bw = new BufferedWriter(fw);//换行bw.newLine();bw.write("Until the end of the world!");System.out.println("内容已更新!");} catch (IOException e) {e.printStackTrace();}finally{try {bw.close();fw.close();} catch (IOException e) {e.printStackTrace();}}}}

0 0