- /**
- *
- */
- package io;
- import java.io.FileReader;
- import java.io.FileWriter;
- /**
- * @author mishi
- *
- */
- public class CopyDemo {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO 自动生成的方法存根
- FileWriter fileWriter = null;
- FileReader fileReader = null;
- try {
- fileReader = new FileReader("D:\\HaxLogs1.txt");
- fileWriter = new FileWriter("D:\\HaxLogs2.txt",true);
- char[] ch = new char[1024];
- int len;
- while((len = fileReader.read(ch))!=-1)
- {
- fileWriter.write(ch,0,len);
- fileWriter.flush();
- }
-
- } catch (Exception e) {
- // TODO: handle exception
- }
- finally
- {
- try {
- if(fileReader != null)
- fileReader.close();
- if(fileWriter!= null)
- fileWriter.close();
- } catch (Exception e2) {
- // TODO: handle exception
- }
-
- }
- }
- }
复制代码
小例子,互相交流 |
|