java.lang.ClassCastException: java.io.ByteArrayInputStream cannot be cast to java.io.FileInputStream
今天在做文件上传的时候遇到一个这样的问题
java.lang.ClassCastException: java.io.ByteArrayInputStream cannot be cast to java.io.FileInputStream
具体出错的代码:
FileInputStream fileInputStream = (FileInputStream)diskFileItems[i].getInputStream();
其中diskFileItems是DiskFileItem[]数组对象,DiskFileItem是Apache的commons-fileupload包里的一个类
在CSDN啥的上面没有找到一个类似的错误,所以直接跑到Stack Overflow上去找,一下就发现了错误的原因,这里的解决办法是:
把FileInputStream改成InputStream就好了
java.lang.ClassCastException: java.io.ByteArrayInputStream cannot be cast to java.io.FileInputStream的更多相关文章
- java.lang.ClassCastException: oracle.sql.TIMESTAMP cannot be cast to java.sql.Timestamp
http://stackoverflow.com/questions/13269564/java-lang-classcastexception-oracle-sql-timestamp-cannot ...
- java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.TextView
最近在学习drawerLayout时,遇到这个bug.如下示: java.lang.ClassCastException: android.widget.RelativeLayout cannot b ...
- 关于android使用ksoap2报Caused by: java.lang.ClassCastException: org.ksoap2.SoapFault cannot be cast to org.ksoap2.serialization.SoapObject
Caused by: java.lang.ClassCastException: org.ksoap2.SoapFault cannot be cast to org.ksoap2.serializa ...
- java.lang.ClassCastException: oracle.sql.CLOB cannot be cast to oracle.sql.CLOB
错误现象: [framework] 2016-05-26 11:34:53,590 -INFO [http-bio-8080-exec-7] -1231863 -com.dhcc.base.db.D ...
- java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText
Caused by: Java.lang.ClassCastException: Android.widget.TextView cannot be cast to android.widget.Ed ...
- 安卓出现错误: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText
Caused by: Java.lang.ClassCastException: Android.widget.TextView cannot be cast to android.widget.Ed ...
- java.lang.ClassCastException:android.widget.Button cannot be cast to android.widget.ImageView
今天遇到一个错误也不知道怎么回事,上网搜了一下: 出现的问题是:java.lang.ClassCastException:android.widget.Button cannot be cast to ...
- java.lang.ClassCastException: android.app.Application cannot be cast to
出这个异常的原因是在项目中添加了新lication类(public class Application extends lication)之后,没有在AndroidManifest.xml中添加该类的 ...
- Android: java.lang.ClassCastException: android.widget.imageView cannot be cast to android.widget.textView异常解决
有时在修改xml文件时,全报这种错误,这个应该是缓存没得到及时更新导致的,可以通过以下方法解决: Eclipse tends to mess up your resources every now a ...
随机推荐
- MSI右键添加管理员运行.reg
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Msi.Package\shell\runas]@="右键以管理员运行MSI& ...
- groupBy 后附加数量和每组百分比
SELECT i_State, n, , ) rat FROM ( SELECT * FROM ( ) n FROM planinfo GROUP BY i_State ) t1 ) s ) t
- js 手机号加密 中间星号表示
var tel = String(this.memberMsg.phoneNo); var dh=tel.substr(0,3)+"******"+tel.substr(8); r ...
- Java中的String真的无法修改吗
Java中String一旦赋值将无法修改,每次对String值的修改都是返回新的String. 如何在不创建新的String对象的情况下,对String的值进行修改呢? String类中的包含一个字段 ...
- Excel 2016在大数据分析领域有了很多的改善
Excel 2016在大数据分析领域有了很多的改善 通常,我们会把大数据分析的整个过程分为五个阶段: 获取获取,数据分析,可视化,发布报告,应用报告. 在获取数据方面,Excel 2016相对Exce ...
- linux命令补全工具
一:下载bash-competion工具 https://files.cnblogs.com/files/zgngg/bash-completion.zip 二:解压 unzip bash-comp ...
- Neo4j-Cypher语言语法
Neo4j-Cypher语言语法 梦飞扬 2018-03-15 264 阅读 Neo4j 本文是记录Neo4j图数据库中实用的Cypher语言语法. Cypher是什么 "Cypher&qu ...
- boost 字符串大小写转换
示例代码如下: #include <boost/algorithm/algorithm.hpp> #include <iostream> using namespace std ...
- 编译安装Python3.6.1
系统:CentOS 7 Python: 3.6.1 去官方网站下载Python的源码包 然后准备开发环境和服务器平台开发 注意:python编译还依赖一个zlib-devel(本人第一次编译就因为不知 ...
- day20 作业
目录 今日作业 1.下面这段代码的输出结果将是什么?请解释. 2.多重继承的执行顺序,请解答以下输出结果是什么?并解释. 3.什么是新式类,什么是经典类,二者有什么区别?什么是深度优先,什么是广度优先 ...