BufferedInputStream in = new BufferedInputStream(doc2.getContent());//读取文件到输入流
OutputStream out = response.getOutputStream();//获取response的输出流
try{
byte[] buf = new byte[2048];//每次读流的字节数
int len=0;
while((len = in.read(buf))>0) {
out.write(buf,0,len);//将图片写入到输出流里面不断返回数据给请求源
}
in.close();
out.flush();
out.close();
}catch (Exception e) {
// TODO: handle exception
LogUtil.error("Get picture with uuid:"+uuid, e);
}finally{
in.close();
out.close();
}

主要就是把图片或文件不断写入到response的输出流

上述在文件比较大的时候性能不好

最好加上缓冲bufferReader 和 bufferWriter

图片支持get请求访问的更多相关文章

  1. Asp.Net Web Api 接口,拥抱支持跨域访问。

    如何让你的 Asp.Net Web Api 接口,拥抱支持跨域访问. 由于 web api 项目通常是被做成了一个独立站点,来提供数据,在做web api 项目的时候,不免前端会遇到跨域访问接口的问题 ...

  2. SpringMvc支持跨域访问,Spring跨域访问,SpringMvc @CrossOrigin 跨域[转]

    SpringMvc支持跨域访问,Spring跨域访问,SpringMvc @CrossOrigin 跨域 原文地址:https://www.cnblogs.com/fanshuyao/p/716847 ...

  3. SpringMvc支持跨域访问,Spring跨域访问,SpringMvc @CrossOrigin 跨域

    SpringMvc支持跨域访问,Spring跨域访问,SpringMvc @CrossOrigin 跨域 >>>>>>>>>>>> ...

  4. 工作随笔——selenium支持post请求,支持自定义header

    背景: 最近在写一个小程序,发现博主所在的地区访问该网站时有防ddos功能验证导致程序不能正常工作. 经过试验发现可以用国外代理ip解决这个问题,但是程序走代理访问延迟高且不稳定. 思路: selen ...

  5. .Net WebApi 支持跨域访问使用 Microsoft.AspNet.WebApi.Cors

    首先导入Cors库,通过程序包管理控制台导入 Install-Package Microsoft.AspNet.WebApi.Cors 引用库之后,我们需要进行简单的配置. 现在WebApiConfi ...

  6. SQLite支持的并发访问数

    SQLite objects created in a thread can only be used in that same thread.The object was created in th ...

  7. spring boot跨域请求访问配置以及spring security中配置失效的原理解析

    一.同源策略 同源策略[same origin policy]是浏览器的一个安全功能,不同源的客户端脚本在没有明确授权的情况下,不能读写对方资源. 同源策略是浏览器安全的基石. 什么是源 源[orig ...

  8. 2019-11-29-asp-dotnet-core-通过图片统计-csdn-用户访问

    title author date CreateTime categories asp dotnet core 通过图片统计 csdn 用户访问 lindexi 2019-11-29 08:26:58 ...

  9. 2019-7-2-asp-dotnet-core-通过图片统计-csdn-用户访问

    title author date CreateTime categories asp dotnet core 通过图片统计 csdn 用户访问 lindexi 2019-7-2 19:21:2 +0 ...

随机推荐

  1. 用TSNE进行数据降维并展示聚类结果

    TSNE提供了一种有效的数据降维方式,让我们可以在2维或3维的空间中展示聚类结果. # -*- coding: utf-8 -*- from __future__ import unicode_lit ...

  2. Ubuntu如何百度云盘下载

    我使用Firefox浏览器下载. (1)先为浏览器下载一个插件:网盘助手 (2)通过终端安装aria2: sudo apt-get install python-apt sudo apt-get in ...

  3. 对lua中__newindex的理解

    阅读了文章后用流程图来总结一下 __newindex的规则: a.如果__newindex是一个函数,则在给table不存在的字段赋值时,会调用这个函数.b.如果__newindex是一个table, ...

  4. app内嵌vue h5,安卓和ios拦截H5点击事件

    安卓和ios拦截h5点击事件,这个函数事件必须是暴漏在window下的 安卓和ios拦截普通h5函数: <div onclick = "show(),window.android.sh ...

  5. Request、Response

    Request Request对象在我们写爬虫发送请求的时候调用,参数如下: url: 就是需要请求的url callback: 指定该请求返回的Response由那个函数来处理. method: 请 ...

  6. [Java Web学习]junit.framework.AssertionFailedError: No tests found in {Class}

    No tests found in com.XXXXX.XXX.inboundPrepService.bizLogic.prepDeterminationEngine.workers.Determin ...

  7. [USACO07OPEN]便宜的回文Cheapest Palindrome

    字串S长M,由N个小写字母构成.欲通过增删字母将其变为回文串,增删特定字母花费不同,求最小花费.        题目描述见上            显然 这是一道区间DP 从两头DP,枚举长度啥的很套 ...

  8. BInsertSort

    #include <bits/stdc++.h> using namespace std; #define MAXSIZE 200000 typedef int KeyType; type ...

  9. Pytho条件判断

    def health_status(): height = float(input("请输入身高(单位:米) :")) weight = float(input("请输入 ...

  10. 事件冒泡(event bubbling)与事件捕捉(event capturing)

    事件捕捉: 单击<div>元素就会以下列顺序触发click 事件. Document => Element html => Element body => Element ...