81,091
社区成员
发帖
与我相关
我的任务
分享
response.flushBuffer();
不是这个
InputStream in = getServletContext().getResourceAsStream("/WEB-INF/hadoop-2.0.2-alpha.tar.gz");
resp.setContentType("application/octet-stream");
resp.addHeader("Content-Disposition", "attachment;filename=" + new String("hadoop-2.0.2-alpha.tar.gz".getBytes("utf-8"),"ISO-8859-1"));
resp.addHeader("Content-Length", "" + in.available());
OutputStream out = resp.getOutputStream();
int len=0;
byte[] b= new byte[512];
while((len=in.read(b))>0){
out.write(b, 0, len);
}
out.flush();
out.close();
in.close();
InputStream in = getServletContext().getResourceAsStream("/WEB-INF/hadoop-2.0.2-alpha.tar.gz");
resp.setContentType("application/octet-stream");
resp.addHeader("Content-Disposition", "attachment;filename=" + new String("hadoop-2.0.2-alpha.tar.gz".getBytes("utf-8"), "ISO-8859-1"));
resp.addHeader("Content-Length", "" + in.available());
OutputStream out = resp.getOutputStream();
int len = 0;
byte[] b = new byte[512];
while ((len = in.read(b)) > 0) {
out.write(b, 0, len);
out.flush();
}
out.close();
in.close();
out.flush();放循环里面,下载268M文件,亲测可用!