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. Code::Blocks 导入Makefile工程

    1)“File -> New -> Project”,选择“Empty Project”并创建. 2)选中 Project,右键,选择“Add files”,将 c/c++ 和 head ...

  2. solr6.4.1 搜索引擎(1)启动eclipse启动

    solr是一个java写的搜索引擎,所以支持java方式的eclipse调试. 本篇文章使用solr版本为6.4.1 一. 环境 solr 下载地址 http://archive.apache.org ...

  3. 廖雪峰Java7处理日期和时间-3java.time的API-1LocalDateTime

    1.java.time提供了新的日期和时间API: LocalDate/LocalTime/LocalDateTime ZoneDateTime/ZoneId Instant Formatter 新A ...

  4. 安装zookeeper遇到的问题

    最近在安装zookeeper的时候遇到了一个问题:调用./zkServer.sh start之后,使用命令telnet localhost 2181,显示访问被拒绝.然后使用netstat查看监听21 ...

  5. Filedset

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. scrapy-logging

    import logging logger = logging.getLogger(__name__) # 当前文件位置 logger.warning('haha') # debug info 201 ...

  7. boost安装缺少libboost_iostreams.so

    编译安装boost库: 1 ./bootstrap.sh 2 ./bjam 3 ./b2 install 但安装boosth后,发现缺少libboost_iostreams.so库,后发现boost库 ...

  8. 解决spring-security session超时 Ajax 请求没有重定向的问题

    开始时, 代码是这样的: $.ajax({ type : "POST", url : sSource, cache : false, dataType : "json&q ...

  9. 收藏 —— KVM网络虚拟化

    http://www.cnblogs.com/CloudMan6/p/5240770.html http://www.cnblogs.com/CloudMan6/p/5289590.html

  10. threading 多线程类继承方式调用

    import threading #线程import time class Work(threading.Thread): def __init__(self,n): threading.Thread ...