zoukankan      html  css  js  c++  java
  • 读取Linux上图片

    /**
         * 读取图片
         * @param path
         * @param response
         * @throws Exception
         */
        public static void showImg(String path,HttpServletResponse response) throws Exception{
            File file = new File(path);
            if (file.exists()) {
                FileInputStream fileIs= new FileInputStream(path);
                int i=fileIs.available(); //得到文件大小
                byte data[]=new byte[i];
                fileIs.read(data); //读数据
                //JSP禁止图片缓存
                response.setHeader( "Pragma", "no-cache" );
                response.addHeader( "Cache-Control", "must-revalidate" );
                response.addHeader( "Cache-Control", "no-cache" );
                response.addHeader( "Cache-Control", "no-store" );
                response.setDateHeader("Expires", 0);
    
                response.setHeader("Content-type", "image/png");
                OutputStream outStream=response.getOutputStream(); //得到向客户端输出二进制数据的对象
                outStream.write(data); //输出数据
                outStream.flush();
                outStream.close();
                fileIs.close();
            }
    
        }
    

      

    ========================================================================================== 我希望每一篇文章的背后,都能看到自己对于技术、对于生活的态度。 我相信乔布斯说的,只有那些疯狂到认为自己可以改变世界的人才能真正地改变世界。面对压力,我可以挑灯夜战、不眠不休;面对困难,我愿意迎难而上、永不退缩。 其实我想说的是,我只是一个程序员,这就是我现在纯粹人生的全部。 ==========================================================================================
  • 相关阅读:
    查看文件方法、vim末行操作
    目录结构、文件管理命令
    计算机快捷键、常用命令、别名、
    Redis 使用与优化
    Redis-Sentinel
    Redis主从复制
    Redis持久化
    API的使用
    Redis安装和配置
    集群搭建(脑裂)
  • 原文地址:https://www.cnblogs.com/weihuang6620/p/9758456.html
Copyright © 2011-2022 走看看