- /**
- *
- */
- package io;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.FileReader;
- import java.io.FileWriter;
- /**
- * @author liangpeng
- *
- */
- public class CopyDemoBuffer {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO 自动生成的方法存根
- BufferedReader bufferedReader = null;
- BufferedWriter bufferedWriter = null;
- try {
- bufferedReader = new BufferedReader(new FileReader("D:\\HaxLogs1.txt"));
- bufferedWriter = new BufferedWriter(new FileWriter("D:\\HaxLogs3.txt"));
- String Line;
- while((Line = bufferedReader.readLine())!=null)
- {
- bufferedWriter.write(Line);
- bufferedWriter.newLine();
- bufferedWriter.flush();
- }
- } catch (Exception e) {
- // TODO: handle exception
- }
- try {
- if(bufferedReader!=null)
- bufferedReader.close();
- if(bufferedWriter!= null)
- bufferedWriter.close();
- } catch (Exception e) {
- // TODO: handle exception
- }
- }
- }
复制代码
代码如上,如有指正,请回复,共同讨论与学习 |
|