java文件操作报错:java.io.FileNotFoundException(拒绝访问)问题
java文件操作报错:java.io.FileNotFoundException(拒绝访问)
错误信息
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);
}总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
spring无法引入注解及import org.springframework.web.bind.annota
本文主要介绍了spring无法引入注解及import org.springframework.web.bind.annotation.*报错的解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2022-06-06


最新评论