JSP文件下载
来源:互联网 发布:linux sqlcmd 编辑:程序博客网 时间:2024/04/28 20:58
File file = new File(URLDecoder.decode(filePath, "GBK"));
filename = new String(filename.getBytes("gb2312"), "iso8859-1");
response.reset();//octet-stream or download
response.setContentType("application/octet-stream; charset=GBK");
response.addHeader("Content-Disposition", "attachment; filename=" + filename);
response.setContentLength((int) file.length());
byte[] buffer = new byte[4096];
BufferedOutputStream output = null;
BufferedInputStream input = null;
// 写缓冲区:
try {
output = new BufferedOutputStream(response.getOutputStream());
input = new BufferedInputStream(new FileInputStream(file));
int n = (-1);
while ((n = input.read(buffer, 0, 4096)) > -1) {
output.write(buffer, 0, n);
}
response.flushBuffer();
} catch (Exception e) {
} // maybe user cancelled download
finally {
if (input != null)
input.close();
if (output != null)
output.close();
out.clear();
out = pageContext.pushBody();
}
- JSP中的文件下载
- JSP中的文件下载
- JSP实现文件下载
- jsp文件下载
- jsp实现文件下载
- jsp的下载文件
- jsp - 下载文件
- JSP实现文件下载
- jsp下载word 文件
- JSP文件下载
- jsp文件下载
- 简单文件下载jsp
- JSP文件下载
- jsp下载文件
- jsp 下载单个文件
- jsp 下载单个文件
- JSP文件下载、上传
- JSP文件下载
- 让人很意外:春晚小品无意间捅破了中国出口创汇真相!
- VC与Matlab混合编程(在VC中调用DLL)
- 输入框为Money与数字
- 关于boxing 和 unboxing
- jsp读流文件并显示
- JSP文件下载
- Project Management in an Agile World
- 物理地址MAC正则表达式
- 如何处理几十万条并发数据?
- 用户权限指派,权限控制页面访问
- ARM学习----指令
- 如何在 Yii 配置中为 MySQL 设置自定义端口
- "#ifndef #define #endif"防止头文件被重复包含
- CSoundBase实现录音与播放