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

IO编程__缓冲字符流__输入、输出

时间:2017-10-06 23:13:06      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:www   代码   system   int   buffere   stat   public   txt   pac   

 

 

一、代码如下

package www.tainiu.wenjian;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class af__FileHuanZiFuLiu__V1 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		BufferedReader br= null;
		BufferedWriter bw= null;
		
		try {
			FileReader fr= new FileReader("d:\\Test.txt");
			br= new BufferedReader(fr);
			
			FileWriter fw= new FileWriter("e:\\Test__1.txt");
			bw= new BufferedWriter(fw);
			
			String s= "";
			while((s=br.readLine()) != null) {
				//System.out.println(s);
				bw.write(s + "\r\n");
			}
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {br.close();bw.close();} catch (IOException e) {e.printStackTrace();}
		}
		

	}

}

 

package www.tainiu.wenjian;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class af__FileHuanZiFuLiu__V2 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		BufferedReader br= null;
		BufferedWriter bw= null;
		
		try {
			//FileReader fr= new FileReader("d:\\Test.txt");
			br= new BufferedReader(new FileReader("d:\\Test.txt"));
			
			//FileWriter fw= new FileWriter("e:\\Test__1.txt");
			bw= new BufferedWriter(new FileWriter("e:\\Test__2.txt"));
			
			String s= "";
			while((s=br.readLine()) != null) {
				//System.out.println(s);
				bw.write(s + "\r\n");
			}
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {br.close();bw.close();} catch (IOException e) {e.printStackTrace();}
		}
		

	}

}

 

IO编程__缓冲字符流__输入、输出

标签:www   代码   system   int   buffere   stat   public   txt   pac   

原文地址:http://www.cnblogs.com/wujianbo123/p/7633137.html

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