response.setContentType("application/zip");
response.setHeader("Location",fileName);
//fileName应该是编码后的(utf-8)
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
response.setContentLength(fileLength);
OutputStream outputStream = response.getOutputStream();
InputStream inputStream = new FileInputStream(zipFilePath);
byte[] buffer = new byte[1024];
int i = -1;
while ((i = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, i);
}
outputStream.flush();
outputStream.close();
inputStream.close();
outputStream = null;
取消
评论