String root= ServletActionContext.getServletContext().getRealPath(File.separator).replace("\\", File.separator);
String fileName = "download.text";
File file = new File(root + fileName);
in = new FileInputStream(file);
// 设置响应正文的MIME类型
response.setContentType("Content-Disposition;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;" + " filename=\""+ URLEncoder.encode(fileName, "UTF-8") + "\"");
// 把本地文件发送给客户端
out = response.getOutputStream();
int byteRead = 0;
byte[] buffer = new byte[512];
while ((byteRead = in.read(buffer)) != -1)
{
  out.write(buffer, 0, byteRead);
}
in.close();
out.close();

downLoad的更多相关文章

  1. csharp: Download SVN source

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  2. Unable to download data from http://ruby.taobao.org/ & don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

    安装cocoapods,记录两个问题! 1.镜像已经替换成了 http://ruby.taobao.org/, 还是不能不能安装cocoapods, 报错:Unable to download dat ...

  3. MDK st-link下载STM32程序出现Internal command error和Error:Flash download failed. Target DLL

    MDK st-link下载STM32程序出现Internal command error和Error:Flash download failed. Target DLL   是因为目标板的芯片处于休眠 ...

  4. kailli linux download

    https://www.offensive-security.com/kali-linux-arm-images/ Courses Certifications Online Labs Penetra ...

  5. Download Excel file with Angular

    源码连接(编写中) 用Angular下载后台返回的Excel文件,用Blob实现,引用FileSaver.js 后台C#代码: [WebMethod] public static byte[] Cal ...

  6. http://www.microsoft.com/en-pk/download/details.aspx?id=40762

    http://www.microsoft.com/en-pk/download/details.aspx?id=40762

  7. [已解决]从微软合作伙伴资源和MSDN下载系统和软件Microsoft download Manager无效

    有个itellyou,更新了所有MSDN的软件包.如果自己有微软的注册账户,还是从微软官网下载比较好.而且对自己账户里的系统和itellyou里的做了对比.发现SHA1码不相同,估计官方分配的序列号也 ...

  8. Error:Flash Download Failed-"Cortex-M3"

    Error:Flash Download Failed-"Cortex-M3"出现一般有两种情况: 1.SWD模式下,Debug菜单中,Reset菜单选项(Autodetect/H ...

  9. cosbench read异常解决办法。 Unable to verify integrity of data download. Client calculated content hash didn't match hash calculated by Amazon S3. The data may be corrupt.

    问题:cosbench read测试failed 报错如下 Cosbench v0.4.2.c4 against Ceph (Hammer) / radosgw / HAproxy's HTTP en ...

  10. Internet Download Manager 6.27.1 中文特别版(IDM)

    软件介绍: 软件名称:Internet Download Manager(IDM) 软件大小:5.09M软件语言:简体中文 软件官网:http://www.internetdownloadmanage ...

随机推荐

  1. c++11 function_typetraits备忘

    function traits. 获取函数或成员函数的返回类型,参数类型,参数长度,类类型. 函数参数列表推断基于typelist:http://www.cnblogs.com/flytrace/p/ ...

  2. 后台自动运行,定期记录定位数据(Hbuilder监听 app由前台切换到后台、切换运行环境的 监听方法)

    http://ask.dcloud.net.cn/question/28090 https://blog.csdn.net/qq_37508970/article/details/86649703 各 ...

  3. linux git pull/push时提示输入账号密码之免除设置

    1.先cd到根目录,执行git config --global credential.helper store命令 [root@iZ25mi9h7ayZ ~]# git config --global ...

  4. 物化视图SQL

    物化视图SQL,如果没有结果集,就证明数据库中不存在物化视图 select a.owner,'' column_name,a.table_name,b.segment_name,b.segment_t ...

  5. Python面向过程编程

    面向过程编程 D:\Document\视频\python20期\day4\视频\面向过程编程 三元表达式示例1 #三元表达式x=10 y=20 res=x if x>y else y print ...

  6. note 0 Python介绍及Python IDE环境安装 Spyder with Anaconda

    高级语言分类 编译型语言(C/C++等) 解释型语言(BASIC.Python等) Python 诞生于1989年,创始人为吉多 范罗苏姆(Guido van Rossum) Python 语言特点 ...

  7. servlet cdi analysis

    CDI中最令人兴奋的功能是允许每个人在Java EE平台中编写强大的扩展性功能,甚至于改变其核心本身.这些扩展性功能是可以完全移植到任何支持CDI的环境中. CDI的一些主要特性 1.类型安全:CDI ...

  8. MySQL Antelope和Barracuda的区别分析

    Antelope是innodb-base的文件格式,Barracude是innodb-plugin后引入的文件格式,同时Barracude也支持Antelope文件格式.两者区别在于: 文件格式 支持 ...

  9. docker 批量删除

    杀死所有正在运行的容器docker kill $(docker ps -a -q) 删除所有已经停止的容器docker rm $(docker ps -a -q) 删除所有未打 dangling 标签 ...

  10. iReport-5.6.0 新建文件为什么是灰色的?新建项目没有选择项?

    从网上下了绿色版和安装版都出现这个问题. 解决:发现原来是有些插件没有激活,进入手动激活就ok了 -->工具-->插件-->已安装 ,选择未激活的手动激活. 激活成功后如下图(和我同 ...