java.io.FileNotFoundException
1. 概述
上传图片到 o:/mmfiles_2017/39973/25444/333.jpg目录下 目录不存在会报标题中的错误
必须先创建目录
2. 方法
File filePath = new File(path);
if(!filePath.exists()){
filePath.mkdirs();//目录是多级 要用带s的方法 否则创建失败
}
3. 代码
InputStream inputStream = uploadFile.getInputStream();
String rootDir = "o:";
String path = rootDir + name.substring(0, name.lastIndexOf("/") + 1);
File filePath = new File(path);
if(!filePath.exists()){
filePath.mkdirs();
}
String fullpathFilename = rootDir + name;
FileOutputStream fos = new FileOutputStream(fullpathFilename);
byte[] b = new byte[1024];
int len = -1;
while((len = inputStream.read(b))!=-1){
fos.write(b, 0, len);
}
fos.close();
java.io.FileNotFoundException的更多相关文章
- java.io.FileNotFoundException: D:\xxx\yyy (拒绝访问。)问题
File file=new File(fileAllName); FileWriter fw=new FileWriter(file); 在Java的 FileWriter 方法时 系统抛出了异常 j ...
- [Storm] java.io.FileNotFoundException: File '../stormconf.ser' does not exist
This bug will kill supervisors Affects Version/s: 0.9.2-incubating, 0.9.3, 0.9.4 Fix Version/s: 0.10 ...
- cxf(3.1.1) 异常Caused by: java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-soap.xml]
Caused by: java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-soap.xml] ...
- QA:java.lang.RuntimeException:java.io.FileNotFoundException:Resource nexus-maven-repository-index.properties does not exist.
QA:java.lang.RuntimeException:java.io.FileNotFoundException:Resource nexus-maven-repository-index.pr ...
- log4j:ERROR setFile(null,true) call failed.java.io.FileNotFoundException: ..\logs\2010-1-19.log (系统找不到指定的路径。)
log4j:ERROR setFile(null,true) call failed.java.io.FileNotFoundException: ..\logs\2010-1-19.log (系统找 ...
- 报错:java.io.FileNotFoundException: (系统找不到指定的路径。)
报错如下: java.io.FileNotFoundException: E:\apache-tomcat-8.0.37\webapps\20161028-FileUpLoad\WEB-INF\fil ...
- 报错:Caused by: java.io.FileNotFoundException: d:\youTemprepository\upload_77faffc1_1580a9240ca__8000_00000001.tmp (系统找不到指定的路径。)
org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-dat ...
- java.io.FileNotFoundException:SESSIONS.ser (系统找不到指定的路径。)
问题如下: java.io.FileNotFoundException: E:\apache-tomcat-8.0.37\work\Catalina\localhost\20161013Shoppin ...
- nested exception is java.io.FileNotFoundException: class path resource [spring/spring-datasource-mog
spring单元測试时发现的问题: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsin ...
- 使用HttpURLConnection下载文件时出现 java.io.FileNotFoundException彻底解决办法
使用HttpURLConnection下载文件时经常会出现 java.io.FileNotFoundException文件找不到异常,下面介绍下解决办法 首先设置tomcat对get数据的编码:con ...
随机推荐
- 使用Pytesseract+Tesseract-OCR识别图片的简单步骤
1.首先安装Pytesseract,这个很简单,直接输入命令 pip install pytesseract即可 2.Tesseract-OCR https://pan.baidu.com/s/1sV ...
- QQ第三方登陆示例
先上图 若想实现QQ登录,需要成为QQ互联的开发者,审核通过才可实现.注册方法可参考链接http://wiki.connect.qq.com/%E6%88%90%E4%B8%BA%E5%BC%80%E ...
- c# Config配置文件读写
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.C ...
- python之类与对象(3)
4. 类的初始化函数__init__(): 本章参考:https://blog.csdn.net/hellocsz/article/details/82795514 原作者: hellocsz 总结 ...
- 【linux】如何查看文件的创建、修改时间
本篇博文旨在介绍Linux下查看文件时间的方法:并介绍如何使用touch指令来进行文件时间的创建以及修改 如何查看文件的时间信息利用stat指令查看文件信息 三种时间的介绍ATime ——文件的最近访 ...
- 2.阿里实人认证 .net 准备工作2 转换demo
1.引入阿里的SDK 2. 搬一下java 的代码 DefaultProfile profile = DefaultProfile.GetProfile( "cn-hangzhou" ...
- ES6新特性整理,你需要了解的ES6知识
ES6是新版本JavaScript语言的标准,上一次标准的制订还是2009年出台的ES5.目前ES6的标准化工作已经完成,14年12月份放出了正式版本. 目前主流的浏览器都支持运行ES6代码,如果你的 ...
- 自学springboot
参考资料 https://www.renren.io/guide/
- Pitfalls of using opencv GpuMat data in CUDA kernel code
Please note that cv::cuda::GpuMat and cv::Mat using different memory allocation method. cv::cuda::Gp ...
- MySQL where 表达式
where 条件表达式 对记录进行过滤,如果没有指定where子句,则显示所有记录. 在where表达式中,可以使用MySQL支持的函数或运算符.