采用常规文件流的读写,将字节流放到response中,在xp系统下下载很快,但是在win7系统下却要等半个小时才能把文件下到本地,文件很小,才几十k。
代码如下:
FileInputStream fin = new FileInputStream(filePath+"/"+fileName);
response.reset();//设置为没有缓存
// response.setContentType("application/x-download;charset=UTF-8");
response.setHeader("Content-Disposition", "attachment;filename="+java.net.URLEncoder.encode(realFileName, "UTF-8"));
response.setContentType("application/x-download");
response.setCharacterEncoding("utf-8");
OutputStream output = response.getOutputStream();
IOUtils.copyLarge(fin, output);
output.flush();各位大侠有没有好的解决方法?