文件上传报错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 ...
随机推荐
- redhat 7.6 安装 inotify-tools 文件监控工具 搭配rsync
1.解压inotify-tools tar -zxvpf inotify-tools-3.14.tar.gz 2.cd 到解压的目录 3../configure 编译,然后失败,提示checking ...
- ubuntu 中怎么安装 jdk 7
Jdk1.7 安装包的下载地址是: http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u4-downloads-1591156. ...
- 记一次NoHttpResponseException问题排查
上传文件程序会有一定的概率提示错误,错误率大概在1%以下,错误信息是:org.apache.http.NoHttpResponseException , s3-us-west-1.amazonaws. ...
- 本周总结(19年暑假)—— Part5
日期:2019.8.11 博客期:111 星期日
- linux查漏补缺-Linux文件目录结构一览表
FHS 标准 FHS(Filesystem Hierarchy Standard),文件系统层次化标准,该标准规定了 Linux 系统中所有一级目录以及部分二级目录(/usr 和 /var)的用途. ...
- Java 后端压缩图片
import java.io.*;import java.util.Date;import java.awt.*;import java.awt.image.*;import javax.imagei ...
- 2017 青岛现场赛 Suffix
Consider n given non-empty strings denoted by s1 , s2 , · · · , sn . Now for each of them, you need ...
- 【剑指Offer面试编程题】题目1371:最小的K个数--九度OJ
题目描述: 输入n个整数,找出其中最小的K个数.例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,. 输入: 每个测试案例包括2行: 第一行为2个整数n,k(1< ...
- EASYUI TREE得到当前节点数据的GETDATA方法
function show() { var node = $('#tt-c71').tree('getSelected'); var data = $('#tt-c71').tree('getData ...
- layui-简单的登录注册界面
register.html 源代码: <!DOCTYPE html> <html lang="en"> <head> <meta char ...