我写了上传的代码可以上传6K的文件但是再大的话就会报错.
java.lang.IllegalStateException: File has been moved - cannot be read again部分代码如下
DataOutputStream out = new DataOutputStream(new FileOutputStream(filePath
+ "\\" + filename));
InputStreamis = null;
try {
is = file.getInputStream();//当文件达到10K的时候运行到这里就报错了.
byte[] buffer = new byte[1024];
while (is.read(buffer) > 0) {
out.write(buffer);// 写入磁盘;
}
return path + filename;
}
catch (IOException exception) {
exception.printStackTrace();
return "";
}
finally {
if (is != null) {
is.close();
}
if (out != null) {
out.close();
}
}
java.lang.IllegalStateException: File has been moved - cannot be read again部分代码如下
DataOutputStream out = new DataOutputStream(new FileOutputStream(filePath
+ "\\" + filename));
InputStreamis = null;
try {
is = file.getInputStream();//当文件达到10K的时候运行到这里就报错了.
byte[] buffer = new byte[1024];
while (is.read(buffer) > 0) {
out.write(buffer);// 写入磁盘;
}
return path + filename;
}
catch (IOException exception) {
exception.printStackTrace();
return "";
}
finally {
if (is != null) {
is.close();
}
if (out != null) {
out.close();
}
}
解决方案 »
- 怎么在javascript的按钮点击事件里,向一个div输出jsp里的内容?
- 做了一个小的登录程序,运行的时候跳出这样的错误,有熟悉的人帮我看看呢
- 如何使用resteasy获取post过来的body?
- 关于hibernate查询效率的问题!
- ★★★★★复杂的投票系统站:不固定的N百个投票,每个投票下选项也不固定.如何控制每个选项投票间隔不低于10分钟?!
- 使用getRequestDispatcher从servlet返回页面时,页面我连接地址全变了
- jfreechart数据轴刻度如何自己设置
- 如何调用 .jar 文件,运行特定的 servlet....
- ====应聘JAVA程序员,拿什么作品好?===
- 如何用类型为button的按钮提交表单内容
- jsp中的<sx:a>标签问题
- 怎么能让spring框架加载加密后的.class文件啊?
你检查一下看路径是否正确
而且我也设置了
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize">
<value>104857600</value>
</property>
<property name="defaultEncoding">
<value>utf-8</value>
</property>
</bean>