解决方案 »
- Could not convert socket to TLS
- struts2 Could not find action or result No result defined for action yy.book.a
- spring+struts 调用set注入成功 但还是抛出空指针异常,望高人指点啊,弄了好多天了
- tomcat配置
- jsp 与oracle的空值问题
- 怎样用JAVASRIPT 删除一个对象,比如 <img><div>
- 在普通的类中如何取得spring配置文件中定义的bean?
- servlet文件怎么才能在JCreator Pro下编译呀?
- 能通过代码屏蔽cache吗?
- No result defined for action com.e6mall.action.manager.IndexAction and result su
- Jsp打印本地文件(PDF或Word)
- 【各位高手帮忙看一下sql呈现界面的问题】好急啊!
应该这样:
InputStream is=item.getInputStream();
int buffer=1024; //定义缓冲区的大小
int length=0;
byte[] b=new byte[buffer];
double percent=0;
FileOutputStream fos=new FileOutputStream(file);
while((length=is.read(b))!=-1){
percent+=length/(double)upFileSize*100D; //计算上传文件的百分比
fos.write(b,0,length); //向文件输出流写读取的数据
session.setAttribute("progressBar",Math.round(percent)); //将上传百分比保存到Session中
}
参考下这个:
JAVA上传源代码