文件下载
来源:互联网 发布:淘宝商家发快递的成本 编辑:程序博客网 时间:2024/04/30 13:01
ServletOutputStream out = appContext.getResponse()
.getOutputStream();
appContext.getResponse().setContentType("application/excel");
appContext.getResponse().setHeader("Content-disposition",
"attachment; " + "filename=temp.xls");
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
FileInputStream fin = new FileInputStream(
fileName);
bis = new BufferedInputStream(fin);
bos = new BufferedOutputStream(out);
byte buff[] = new byte[2048 * 8];
int bytesRead;
while (-1 != (bytesRead = bis.read(buff, 0, buff.length)))
bos.write(buff, 0, bytesRead);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (bis != null)
bis.close();
if (bos != null)
bos.close();
}
}
- 下载图片,下载文件
- 文件下载
- 文件下载
- 文件下载
- 文件下载
- 文件下载
- 文件下载
- 下载文件
- 文件下载
- 下载文件
- 文件下载
- 文件下载
- 下载文件
- 文件下载
- 下载文件
- 下载文件
- 文件下载
- 下载文件
- Java 同步机制浅谈
- 静态变量 static 全局变量 global
- 面向Java程序员的Ajax:构建动态Java程序
- 趣文:IT动物园
- 常用软件滤波方法及其示例程序
- 文件下载
- [转].NET牛人应该知道些什么
- Linux系统下的多线程编程入门
- 需要注意的C++中11个要点
- 什么是Ajax?
- 商业智能BI的困惑
- 触发器的样例,存储过程样例
- U-boot-1.1.6-2008R1到vdsp5(bf561)的移植记录(17): Entry.h
- Ajax让Web设计人性化:新应用 新体验