JAVA 流下载文件 360下载是ACTION的原因分析


BufferedInputStream bis = null;
BufferedOutputStream bos = null;
OutputStream fos = null;
InputStream fis = null;
String filepath=path;//本地绝对路径
File uploadFile = new File(filepath);
fis = new FileInputStream(uploadFile);
bis = new BufferedInputStream(fis);
reponse.reset();
fos = reponse.getOutputStream();
bos = new BufferedOutputStream(fos);
reponse.setContentType("text/plain");
reponse.setHeader("Content-disposition","attachment; filename="+uploadFile.getName());
int bytesRead = 0;
//用输入流进行先读,然后用输出流去写,唯一不同的是我用的是缓冲输入输出流
// byte[] buffer = new byte[8192];
// while ((bytesRead = bis.read(buffer, 0, 8192)) != -1) {
// bos.write(buffer, 0, bytesRead);
// }
FileCopyUtils.copy(fis, bos);//spring工具类直接流拷贝
bos.flush();
fis.close();
bis.close();
fos.close();
bos.close();

这个功能IE,firef是好的 但是在360下载时候 我分析是直接下载了ACTION
直接输出流到360,360有个下载管理工具来识别这个请求的文件名之类的信息.然后需要点击确定后(此后会再次请求一次刚才的地址),才会具体把这个输出的东西保存为具体文件.这个时候就把action下载出来了(可能这个地方说ACTION有些歧义)
这里请求了两次那个文件.
把360下载换成IE(工具-》下载器-》设置-》默认下载工具为IE).这个问题就解决了
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值