java TestFileCopy测试(字符流)

package org.lunzi.test.io;

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

public class TestFileCopy {

public static void main(String[] args) {
int b = 0;
String fileReadPath = "E:/tianzhi/index.jsp";
String fileWritePath =
"E:/org/test.jsp";
FileReader in = null;
FileWriter out = null;

try {
in = new FileReader(fileReadPath);
out = new FileWriter(fileWritePath);
while ((b = in.read()) != -1) {
out.write(b);
}
out.flush();
out.close();
in.close();

} catch (FileNotFoundException e) {
System.out.println(
"找不到指定文件");
System.exit(-1);
} catch (IOException e) {
System.out.println(
"文件复制错误");
System.exit(-1);
}

System.out.println(
"文件已复制");

}

}

lunzi   2008-11-08 20:23:26 评论:1   阅读:381   引用:0

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

验证码: (如不清楚,请刷新)

Copyright@2004-2010 powered by YuLog