String filename = req.getParameter("filename");
res.reset();
res.setContentType("application/x-msdownload"); // windows
res.setHeader("Content-Disposition", "attachment; filename=/""
+ new String(filename.getBytes("gb2312"), "iso8859-1") + "/"");
// 新建文件输入输出流
OutputStream output = null;
FileInputStream fis = null;
// 新建File对象
File f = new File(this.getFileUIR() + "//" + filename);
// 新建文件输入输出流对象
output = res.getOutputStream();
fis = new FileInputStream(f);
// 设置每次写入缓存大小
byte[] b = new byte[10240];
// out.print(f.length());
// 把输出流写入客户端
int i = 0;
while ((i = fis.read(b)) > 0) {
output.write(b, 0, i);
}
output.flush();
output.close();
fis.close();