zoukankan      html  css  js  c++  java
  • java用流的方式加载图片

    前端:

    <img ng-show="photo" class="vertical_b" id="photoImg" src="http://localhost:9999/manage-admin/filemanager/prevViewByPath.action?filePath=cf532711-6ba8-4259-8c30-1dbb13fe3a82.jpg">

    后端:

    /**
         * @throws IOException 
         * @throws FileNotFoundException 
         * 功能:预览
         * @param
         * @return
         * @throws   
         */
        public String prevViewByPath() throws IOException{
            String catalinaHome = filePathConfig.getFileUploadPath();
            String targetDirectory = catalinaHome + "/upload/";
            String filedownload = targetDirectory + filePath;
            File f = new File(filedownload);
            if(!f.exists()){
                return null;
            }
            FileInputStream fis = new FileInputStream(f);
            OutputStream out = getResponse().getOutputStream();
            byte[] bs = new byte[1024];
            while ((fis.read(bs) != -1)) {
                out.write(bs);
            }
            out.flush();
            out.close();
            out = null;
            fis.close();
            return null;
        }
  • 相关阅读:
    博客
    参考博客
    KMP
    串匹配
    简单数论
    B
    各种常用函数的模板以及自己的测试数据
    header
    memcached的图形界面监控
    缓存策略
  • 原文地址:https://www.cnblogs.com/coder-lzh/p/9546092.html
Copyright © 2011-2022 走看看