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 ...
随机推荐
- [转]IOS UIView 之属性篇
[转载自:IOS UIView 之属性篇 From CSDN] UIView 继承于UIResponder 所遵守的协议有 NSCoding .UIAppearance. UI ...
- [web]Servlet中的Listener和Filter
建议先看看 ——> Servlet工作原理 一.Listener 在Tomcat服务中,Listener的设计是基于观察者模式的,目前在Servlet中提供6中两类事件的观察者接口,它们分别是: ...
- esp32 blink实验
#include<stdio.h>#include"freertos/FreeRTOS.h"#include"freertos/task.h"#in ...
- jvm内存分部
首先我们必须要知道的是 Java 是跨平台的.java常用的名词有jdk,jre,jvm jdk包括后两者,是开发者工具集, jre表示java运行环境, jvm是java虚拟机,是java夸平台的保 ...
- PHP 数组与CSV文件互转
项目说明 数组导出CSV,ZIP文件,CSV,ZIP文件还原数组(Array export file,file restore array)适用于导入导出会员,商品信息注意:读取中文文件名文件.数据时 ...
- 【Python】Excel数据处理
1.环境准备 > python2.7 > xlrd,xlwt模块下载与安装,前者用来读取excel文件,后者用来写入excel文件 2.实战案例 案例场景: > excel1中包含某 ...
- mysql入门与进阶
MySQL入门与进阶 需求:对一张表中的数据进行增删改查操作(CURD) C:create 创建 U:update 修改 R:read 读|检索 查询 D:delete 删除涉及技术:数据库 1.数据 ...
- 转如何检查数据库是否处于一致性的状态 以及 如果在DG 库上备份,恢复成一个主库
##sample 0 不完全恢复之后,open resetlogs之前,怎么快速的检查数据库是否处于一致性的状态?https://blog.csdn.net/msdnchina/article/det ...
- Kubernetes Running Locally
1. Requirements 1) Linux Not running Linux? Consider running Minikube, or on a cloud provider like G ...
- Jmeter基础元件
测试计划 1.Test Plan (测试计划) 用来描述一个性能测试,包含与本次性能测试所有相关的功能.也就说JMeter创建性能测试的所有内容是于基于一个计划的. 下面看看一个计划下面都有哪些功能模 ...