1、package com.test.iostream;import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;/* 字符缓冲流测试* 复制文件* author Administrator*/public class BufferSteamTest_01 public static void main(String args) long start = System.curren
2、tTimeMillis();copy();/复制字符文件long end = System.currentTimeMillis();System.out.println(“所需时间: “+(end-start)+“毫秒“);public static void copy() BufferedWriter bfw = null;BufferedReader bfr = null;try bfr = new BufferedReader(new FileReader(“c:sshmodel.log“);/读数据源bfw = new BufferedWriter(new FileWriter(“f:
3、IOtestBuffer.txt“);/写数据处String str = null;while(str = bfr.readLine() != null)bfw.write(str);bfw.newLine();bfw.flush(); catch (Exception e) throw new RuntimeException(“复制失败!“ ); finally if(bfw!=null)try bfw.close(); catch (IOException e) throw new RuntimeException(“缓冲写入流关闭失败!“);if(bfr != null)try bfr.close(); catch (IOException e) throw new RuntimeException(“缓冲读取流关闭失败!“);