Buffer copy file

View Code
import java.io.*;
class copy_demo
{
    public static void main(String[] args)throws Exception
    {
        FileReader fr=new FileReader("abc.txt");
        BufferedReader bufr=new BufferedReader(fr);
        FileWriter fw=new FileWriter("copy_abc.txt");
        BufferedWriter bufw=new BufferedWriter(fw);
        int num=0;
        while((num=bufr.read())!=-1)
        {
            String st=bufr.readLine();
            bufw.write(st); 
            bufw.newLine();
            System.out.println((char)num);
            
        }
        for(int x=0;x<10;x++)
        {
            String ss=bufr.readLine();
            if(ss!=null)System.out.println(ss);
            
        }
        bufw.close();
    }
}

 

posted on 2012-10-16 15:36  蝌蚪的精神  阅读(144)  评论(0编辑  收藏  举报

导航