日期:2014-05-18 浏览次数:20731 次
String filePath=request.getRealPath("/..");
String filename = "total.zip";
File fileLoad = new File(filePath, filename);
FileInputStream in = null; // 输入流
OutputStream out = response.getOutputStream();
byte b[] = new byte[1024];
try {
response.setContentType("application/x-msdownload;");
response.setHeader("Content-disposition", "attachment; filename="
+ new String(filename.getBytes("UTF-8"), "UTF-8"));
// download the file.
in = new FileInputStream(fileLoad);
int n = 0;
while ((n = in.read(b)) != -1) {
out.write(b, 0, n);
}&nbs