public String copyFile(String oldPath) {
try {
String str = "";
File oldfile = new File(oldPath);
if (oldfile.exists()) { // 文件存在时
FileReader fr = new FileReader(oldPath); // 读入原文件
BufferedReader in = new BufferedReader(fr);
String s = "";
while ((s = in.readLine()) != null) {
str += s;
str += "\n";
}
in.close();
fr.close();
} else {
System.out.println("can not find the file");
return "can not find the file";
}
return str;
} catch (Exception e) {
System.out.println("复制单个文件操作出错");
e.printStackTrace();
return "can not find the file";
}
}
posted on 2006-06-08 14:32
fish的Blog 阅读(1270)
评论(0) 编辑 收藏 所属分类:
Jsp