码迷,mamicode.com
首页 > 其他好文 > 详细

BufferedReader 和 BufferedWriter

时间:2015-06-14 18:18:36      阅读:99      评论:0      收藏:0      [点我收藏+]

标签:

package h15;

import java.io.*;

public class BufferedReaderDemo {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        BufferedReader br = null;
        BufferedWriter bw = null; 
        FileReader fr;
        FileWriter fw;
        try {
            fr = new FileReader("e:/a.txt");
            fw = new FileWriter("e:/c.txt");
            br = new BufferedReader(fr);
            bw = new BufferedWriter(fw);
            String s="";
            while((s=br.readLine())!=null){
                bw.write(s);
            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }finally{
            try {
                br.close();
                bw.close();
            } catch (Exception e2) {
                // TODO: handle exception
                e2.printStackTrace();
            }
        }
        
        
    }

}

 

BufferedReader 和 BufferedWriter

标签:

原文地址:http://www.cnblogs.com/hzzhero/p/4575263.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!