提高效率,读取每一行

package study;
import java.io.*;
public class Wha {
	public static void main(String[] args) {
	FileReader fr=null;
	FileWriter fw=null;
	BufferedReader br=null;
	BufferedWriter bw=null;
	try {
		fr=new FileReader("c:\\f.txt");
		br=new BufferedReader(fr);
		try {
			fw=new FileWriter("c:\\d.txt");
			bw=new BufferedWriter(fw);
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		String s="";
		int n=0;
		try {
			while((s=br.readLine())!=null)
			{
				bw.write(s+"\r\n");
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	finally
	{
		try {
			br.close();
			bw.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	}

}

发布了87 篇原创文章 · 获赞 2 · 访问量 4501

猜你喜欢

转载自blog.csdn.net/qq_41588302/article/details/104032733
今日推荐