文件上传报错java.io.FileNotFoundException拒绝访问

局部代码如下:
File tempFile = new File("G:/tempfileDir"+"/"+fileName);
if(!tempFile.exists()){
tempFile.mkdirs();
System.out.println(tempFile.exists());
}
运行后发现,新建的目录里面应该是个文件,但是确实个路径

然后修改代码如下
File tempFile = new File("G:/tempfileDir"+"/"+fileName);
if(!tempFile.getParentFile().exists()){
tempFile.getParentFile().mkdirs();//创建父级文件路径
tempFile.createNewFile();//创建文件
System.out.println(tempFile.exists());
}
报错java.io.FileNotFoundException,导致拒绝访问,往往是没有相关文件或者是文件和路径创建时调用方法调用错了,需要注意。
文件上传报错java.io.FileNotFoundException拒绝访问的更多相关文章
- 关于SpringMVC项目报错:java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/xxxx.xml]
关于SpringMVC项目报错:java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/xxxx ...
- 解决springMVC文件上传报错: The current request is not a multipart request
转自:https://blog.csdn.net/HaHa_Sir/article/details/79131607 解决springMVC文件上传报错: The current request is ...
- 完美解决JavaIO流报错 java.io.FileNotFoundException: F:\ (系统找不到指定的路径。)
完美解决JavaIO流报错 java.io.FileNotFoundException: F:\ (系统找不到指定的路径.) 错误原因 读出文件的路径需要有被拷贝的文件名,否则无法解析地址 源代码(用 ...
- keytool 错误: java.io.FileNotFoundException: 拒绝访问
keytool 错误: java.io.FileNotFoundException: 拒绝访问 打开命令行,切换到D:\AndroidStudioProjects\MyApplication\app目 ...
- 关于spark入门报错 java.io.FileNotFoundException: File file:/home/dummy/spark_log/file1.txt does not exist
不想看废话的可以直接拉到最底看总结 废话开始: master: master主机存在文件,却报 执行spark-shell语句: ./spark-shell --master spark://ma ...
- Spark启动报错|java.io.FileNotFoundException: File does not exist: hdfs://hadoop101:9000/directory
at org.apache.spark.deploy.history.FsHistoryProvider.<init>(FsHistoryProvider.scala:) at org.a ...
- .net core 3.0web_razor page项目_使用中间件接受大文件上传报错_httpRequest.Form threw an exception of type Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException_Request body too large
前言:在web项目的.net framework时文件上传时,自己常用一般处理程序接受上传文件,上传文件的大小限制是可以项目的webconfig里配置. 到core项目使用一般处理程序变成了中间件 ...
- springboot文件上传报错
异常信息: org.springframework.web.multipart.MultipartException: Could not parse multipart servlet reques ...
- 文件上传报错:Unknown: file created in the system's temporary directory
nginx+php下文件上传成功,但会有错误提示如下: <b>Notice</b>: Unknown: file created in the system's tempor ...
随机推荐
- 在PyCharm中自动添加文件头、时间日期等信息
初次安装使用PyCharm,在新建.py文件时会发现文件头并没有什么信息,因此,使用模板会比较方便.方法如下: 1.打开PyCharm,选择File--Settings 2.依次选择Editor--- ...
- 一个DBA的雄心壮志
math-liu, 一个甲方的DBA,同时他还有另外一个名字“怕提神”.在某甲方工作的他最近这几年如打了鸡血一般工作起来完全由拼命三郎的那股劲,据说能唯一使他感到一丝鼓励和安慰的是以下这两位大牛前辈. ...
- 问题解决 : org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
问题分析: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): ,即在mybatis中da ...
- kubernetes 1.17.2 kubeadm部署 证书修改为100年
[root@hs-k8s-master01 ~]# cd /data/ [root@hs-k8s-master01 data]# ls docker [root@hs-k8s-master01 dat ...
- Java 对不同类型的数据文件的读写操作整合器[JSON,XML,CSV]-[经过设计模式改造](2020年寒假小目标03)
日期:2020.01.16 博客期:125 星期四 我想说想要构造这样一个通用文件读写器确实不容易,嗯~以后会添加更多的文件类型,先来熟悉一下文件内容样式: <?xml version=&quo ...
- Hive的存储和MapReduce处理——数据清洗(Part3)
日期:2019.11.17 博客期:118 星期日 这几天在写程序的时候虚拟机崩了,无语~所以重新从最初的状态开始配环境,重新整理之前的所有代码程序.
- PaperReading20200223
CanChen ggchen@mail.ustc.edu.cn AdaBatch Motivation: Current stochastic gradient descend methods u ...
- 浏览器之本地缓存存储 localStorage 和 sessionStorage的区别以及用法
区别: localStorage永久保存在浏览器 :sessionStorage在浏览器关闭之后存储的数据就会销毁 用法:两者用法差不多,但是取值有所不同 编辑页面逻辑代码为: 这是给 id=btn ...
- MySQL复制(一)--复制概述
MySQL复制(replication)文档集合:1.复制概述2.基于二进制日志文件位置(binlog)配置复制3.基于全局事物标识符(GTID)配置复制4.多源复制5.级联复制6.半同步复制7.延迟 ...
- 「Luogu2264」情书
传送门 Luogu 解题思路 字符串模拟SB题,STL随便搞. 详情见代码. 细节注意事项 STL总得会吧. 参考代码 #include <algorithm> #include < ...