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 ...
随机推荐
- 手动博客重定向 https://www.cnblogs.com/kelthuzadx/
https://www.cnblogs.com/kelthuzadx/ 博客狂魔又㕛叒换地址了
- Linux的vim和vi编辑器
vim和vi的基本介绍 所有的Linux 系统都会内建vi 文本编辑器. Vim 具有程序编辑的能力,可以看做是Vi的增强版本,可以主动的以字体颜色辨别语法的正确性,方便程序设计. 代码补完.编译及错 ...
- Django---错误
ValueError: Dependency on app with no migrations: users 先 python manage.py makemigration 后 python ma ...
- JQuery的get、post、ajax方法
1.jQuery $.get() 方法 $.get() 方法通过 HTTP GET 请求从服务器上请求数据. jQuery.get( url, [data], [callback] ): 参数: ...
- POJ_2886 Who Gets the Most Candies? 【二分+树状数组】
一.题目 POJ2886 二.分析 这个题目吧,开始没读懂,做的时候也没懂,WA的时候懂了.假设是第p个出圈的人有一个对应的因子个数$F(p)$,那么,题目求的就是这个$F(p)$最大的对应的人. 1 ...
- 01-复杂度2 Maximum Subsequence Sum (25 分)
Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to ...
- 使用webbench工具测试网站访问压力
介绍 Webbench是一个在Linux下使用的网站压测工具.它使用fork()模拟多个客户端 同时访问我们设定的URL,测试网站在压力下工作的性能, 最多可以模拟3万个并发连接去测试网站的负载能力. ...
- 基于两阶段提交的分布式事务实现(UP-2PC)
引言:分布式事务是分布式数据库的基础性功能,在2017年上海MySQL嘉年华(IMG)和中国数据库大会(DTCC2018)中作者都对银联UPSQL Proxy的分布式事务做了简要介绍,受限于交流形式难 ...
- python创建目录并更改权限的代码
如下代码段是关于python创建目录并更改权限的代码. import os os.mkdir("foo", 0666)
- Win32创建异形窗口
大家都见过在windows下各种气泡窗口.输入法窗口以及其他一些窗口,这些窗口看起来不像传统的windows窗那样,上面是标题栏,下面是窗口的客户区.这些窗口形状各异,可以是一个多边形,一幅图,甚至是 ...