java.io.FileNotFoundException: D:\e (拒绝访问。)
这是因为访问的文件地址是文件夹而不是,具体的文件,把路径改为具体的文件就可以了。
参考文章:https://blog.csdn.net/w405722907/article/details/78610485
/**
* 查看某个文件夹下所有的文件 并删除文件
*/
@RestController
public class One { /**
*查看某个文件夹下所有的文件
* @param args
*/
public static void main(String[] args) {
/*File file1 = new File("D:\\e\\test.txt");
delete(file1);
File file = new File("D:" + File.separator);
print(file);*/
//"D:\\门头沟国高新2018年度(管委).xlsx"
try {
download("门头沟国高新2018年度(管委).xlsx");
} catch (IOException e) {
e.printStackTrace();
}
/* String s = "D:/e/D:/门头沟国高新2018年度(管委).xlsx (文件名、目录名或卷标语法不正确。)";
String substring = s.substring(8, s.length());
System.out.println(substring);*/
} /**
* 打印某个文件夹下的所有文件名字
* @param file
*/
public static void print(File file){
if (file != null){
if (file.isDirectory()){
File[] files = file.listFiles();
if (files != null){
for (int i = 0; i < files.length; i++){
System.out.println(files[i]);
}
}
}
}
} /**
* 删除某个文件
* @param file
*/
public static void delete(File file){
if (file != null && file.exists()){
boolean delete = file.delete();
System.out.println(delete);
}
} /**
* 下载某个文件
* @param fileName
* @throws IOException
*/
public static void download(String fileName) throws IOException {
FileOutputStream fileOutputStream = null;
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream("D:\\" + fileName);
fileOutputStream = new FileOutputStream("D:\\e\\" + fileName);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
byte[] bytes = new byte[1024];
while (bufferedInputStream.read(bytes) != -1){
bufferedOutputStream.write(bytes);
}
bufferedOutputStream.flush();
bufferedOutputStream.close();
bufferedInputStream.close();
}
}
java.io.FileNotFoundException: D:\e (拒绝访问。)的更多相关文章
- java.io.FileNotFoundException:my-release-key.keyStore拒绝访问
安卓生成APK的时候,生成密钥的时候报java.io.FileNotFoundException:my-release-key.keyStore拒绝访问的错误 这是因为权限问题:你的jdk目录在c盘, ...
- Java解决java.io.FileNotFoundException: E:\work\work (拒绝访问。)
一.问题 在使用FileInputStream或FileOutputStream时会遇到如下问题1和问题2. 问题1: java.io.FileNotFoundException: .\xxx\xxx ...
- java.io.FileNotFoundException: E:\work\work (拒绝访问。)
转载自:https://blog.csdn.net/YQS_Love/article/details/51959776 一.问题 在使用FileInputStream或FileOutputStream ...
- 文件上传报错java.io.FileNotFoundException拒绝访问
局部代码如下: File tempFile = new File("G:/tempfileDir"+"/"+fileName); if(!tempFile.ex ...
- java.io.FileNotFoundException: D:\xxx\yyy (拒绝访问。)问题
File file=new File(fileAllName); FileWriter fw=new FileWriter(file); 在Java的 FileWriter 方法时 系统抛出了异常 j ...
- keytool 错误: java.io.FileNotFoundException: 拒绝访问
keytool 错误: java.io.FileNotFoundException: 拒绝访问 打开命令行,切换到D:\AndroidStudioProjects\MyApplication\app目 ...
- java.io.FileNotFoundException异常,一是“拒绝访问”,二是“系统找不到指定路径”
关于java.io.FileNotFoundException异常 因为这个异常抛出俩种情况:一是“拒绝访问”,二是“系统找不到指定路径” 这里只讲明什么时候抛拒绝访问,什么时候抛找不到指定路径. 原 ...
- Android java.io.FileNotFoundException:*** (Permission denied)
自从离开上海来到杭州之后,陆续接触了Android,Python,C++,OpenCV,最为一个新人来说,一路上遇到了很多坑,幸运的是 这互联网的强大(大傻子我还是蛮喜欢的哈),一路填填补补总算走了下 ...
- com.jcraft.jsch.JSchException: java.io.FileNotFoundException: file:\D:\development\ideaProjects\salary-card\target\salary-card-0.0.1-SNAPSHOT.jar!\BOOT-INF\classes!\keystore\login_id_rsa 资源未找到
com.jcraft.jsch.JSchException: java.io.FileNotFoundException: file:\D:\development\ideaProjects\sala ...
随机推荐
- vue标签内循环数据逗号分隔
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Matlab title正确显示下划线
前言 使用matlab中title语句,直接敲下划线无法正确显示. title('MSB_data'); 流程 使用如下语句即可:直接字符串转译 title('MSB_data','Interpret ...
- vue + elementui 使用多选按钮实现单选功能
CommonRadio.vue <template> <div> <el-checkbox-group v-model="checkList" @ch ...
- [AIR] NativeExtension在IOS下的开发实例 --- IOS项目的创建 (一)
来源:http://bbs.9ria.com/thread-102037-1-1.html 最近看到本版块的很多关于NativeExtension的应用.但是都是在Android下面的应用.也有很多朋 ...
- gin 页面重定向
两种gin页面重定向方式 redirect: package main import ( "github.com/gin-gonic/gin" "net/http&quo ...
- 过滤器实现Token验证(登录验证+过期验证)---简单的实现
功能:登录验证+过期验证+注销清除cookie+未注销下关闭或刷新浏览器仍可直接访问action概述:token只存在客户端cookie,后端AES加密+解密+验证,每一次成功访问action都会刷新 ...
- Not so Mobile UVA - 839(二叉树的先序遍历)
#include<iostream> using namespace std; int solve(int &W) /*这里一定要用引用,为了赋给它值*/ { int wl, dl ...
- Oracle建立DBLINK的详细步骤记录
测试条件:假设某公司总部在北京,新疆有其下属的一个分公司.在本次测试中,新疆的计算机为本地计算机,即本要的IP地址为:192.168.1.100 北京的总部有一个集中的数据库,其SID是SIDBJ,用 ...
- 物体检测方法(1) - YOLO 详解
最近遇到一些卡证识别的检测问题,打算先把理论知识梳理一下,随后还会梳理一版代码注释. 以前的region+proposal来检测的框架,这一系列速度和精度不断提高,但是还是无法达到实时.存在的主要问题 ...
- 洛谷-P2661 信息传递——有向图中的最小环
题意 给定一个 $n$ 个结点有向图,求其中最小环的大小.($n \leq 200000$). 分析 由于每条点出度都为1且满足传递性,可以用并查集做. 如果有一条从x到y的有向边,那么y就是x的父亲 ...