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的更多相关文章

  1. java.io.FileNotFoundException: D:\xxx\yyy (拒绝访问。)问题

    File file=new File(fileAllName); FileWriter fw=new FileWriter(file); 在Java的 FileWriter 方法时 系统抛出了异常 j ...

  2. [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 ...

  3. 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] ...

  4. 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 ...

  5. 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 (系统找 ...

  6. 报错:java.io.FileNotFoundException: (系统找不到指定的路径。)

    报错如下: java.io.FileNotFoundException: E:\apache-tomcat-8.0.37\webapps\20161028-FileUpLoad\WEB-INF\fil ...

  7. 报错:Caused by: java.io.FileNotFoundException: d:\youTemprepository\upload_77faffc1_1580a9240ca__8000_00000001.tmp (系统找不到指定的路径。)

    org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-dat ...

  8. java.io.FileNotFoundException:SESSIONS.ser (系统找不到指定的路径。)

    问题如下: java.io.FileNotFoundException: E:\apache-tomcat-8.0.37\work\Catalina\localhost\20161013Shoppin ...

  9. nested exception is java.io.FileNotFoundException: class path resource [spring/spring-datasource-mog

    spring单元測试时发现的问题: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsin ...

  10. 使用HttpURLConnection下载文件时出现 java.io.FileNotFoundException彻底解决办法

    使用HttpURLConnection下载文件时经常会出现 java.io.FileNotFoundException文件找不到异常,下面介绍下解决办法 首先设置tomcat对get数据的编码:con ...

随机推荐

  1. 在iOS7中修改键盘Return键的类型

    今天将之前运行在iOS7之前的一段代码拿出来,在iOS7的机器上运行,发现键盘上的ReturnKeyType不能被修改了. 经过几番查找资料,了解到iOS7中UISearchBar的结构发生了变化,将 ...

  2. iOS中的自由桥接

    [摘抄自<iOS 6编程实战>] 与Objective-C库不同,我们在Objective-C中使用标准C语言和Core Foundation类库(CF*方法)不会遵循那些命名约定.这意味 ...

  3. orange

    选型:使用orange系统 orange与kong的比较1.kong整体代码上较凌乱, orange相对较有条理2.kong本身不支持后台管理页面,只能通过api方式增,删,改plugin, oran ...

  4. Selenium使用parameterized库进行参数化

    在我们做自动化测试的时候参数化是必不可少的,那么要怎么去做参数化呢?咱们来看下unittest+parameterized是怎么实现的 1.https://github.com/wolever/par ...

  5. JAVA 集合随笔

    JAVA中提供了现成操纵数据的集合,使得我们在开发中基本不用自己动手实现复杂的数据结构,来保存和操纵数据. 所以当我们有了基本的数据结构知识,会合理利用JAVA提供的集合就好啦. JDK1.8;(仅列 ...

  6. docker-compose部署mysql配置

    docker-compose部署mysql配置文件如下 version: ' services: mysql: image: mysql environment: - MYSQL_ROOT_PASSW ...

  7. leetcode 4 - binary search

    注意: 1)需要保证nums1 的长度比 nums2 的长度小:(否则vector指针会越界) 2)  当分割线(partition)在首或尾时,用INT_MIN 和 INT_MAX 代替. 思路: ...

  8. Stack — 20181121

    12. Min Stack public class MinStack { Stack<Integer> stack; Stack<Integer> minStack; pub ...

  9. 2019.4.4 盒模型&定位&浮动

    盒模型 盒模型 除了图片表单元素之外,基本所有标签都可以看做一个盒子 盒模型的要素 父子关系之间用padding 兄弟关系之间用margin margin padding border 后面跟的值的顺 ...

  10. storm(4)-topology的组成-stream/spout/blot/

    topology包含:stream.spout.blot. topology会一直运行,除非进程被杀死. 1.stream stream=tuple=event(CEP中的)=发送的报文.键值对(一个 ...