soft_xiaohui 发表于 2013-1-15 01:56:16

文件下载

BufferedInputStream bis = new BufferedInputStream(new FileInputStream(fileName));
   byte[] stb = new byte;
   int length = 0;
   length = bis.read(stb);
   bis.close();
   response.setContentLength(length);
   BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream(), length);
   bos.write(stb, 0, length);
   bos.close();
加粗这段是下载时后台内存溢出的原因,文件稍大一点就溢出了
 
解决方案(SpringUtils):
FileInputStream is = new FileInputStream(file);
FileCopyUtils.copy(is, os);
 
----公司案例,待学习。
页: [1]
查看完整版本: 文件下载