赞
踩
Exception in thread "main" java.io.FileNotFoundException: e:b (拒绝访问。)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at com.eleven.SevenDemo04.copyFile(SevenDemo04.java:44)
at com.eleven.SevenDemo04.main(SevenDemo04.java:21)
1)修改前:
public static void main(String[] args) throws Exception {
File source = new File("d:\aa\aa.txt"); // 源目标路径
File dest = new File("e:\bb\"); // 目标路径
copyFile(source, dest);
}
2)修改后:
错误的原因是读取的目录后面忘加了文件名!
public static void main(String[] args) throws Exception {
File source = new File("d:\aa\aa.txt"); // 源目标路径
File dest = new File("e:\bb\" + source.getName()); // 目标路径
copyFile(source, dest);
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。