/*
* 通过缓冲区复制一个文件:
* */
import java.io.*;
public class CopyTextByBuf {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args){
// TODO Auto-generated method stub
BufferedReader bufr = null;
BufferedWriter bufw = null;
try
{
/*FileReader fr = new FileReader("D:\\FaceProv.log");
FileWriter fw = new FileWriter("C:\\java.txt");
BufferedReader bufr = new BufferedReader(fr);
BufferedWriter bufw = new BufferedWriter(new FileWriter(fw));
*/
bufr = new BufferedReader(new FileReader("D:\\FaceProv.log"));
bufw = new BufferedWriter(new FileWriter("C:\\java.txt"));
String line = null;
while((line = bufr.readLine())!=null)
{
bufw.write(line);//一次读一行
bufw.newLine();//换行
}
}
catch (IOException e) {
// TODO Auto-generated catch block
throw new RuntimeException("读写操作失败");
}
finally
{
try
{
if(bufr!=null)
bufr.close();
} catch (IOException e) {
// TODO Auto-generated catch block
throw new RuntimeException("读取关闭操作失败");
}
try {
if(bufw!=null)
bufw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
throw new RuntimeException("写入关闭操作失败");
}
}
}
}