java實現 瀏覽器圖片展示


功能簡單,直接貼代碼

private void imageShow(HttpServletResponse response, @ModelAttribute("url") String url)
            throws IOException {
        String s2 = new String(url.getBytes("ISO-8859-1"),"utf-8");
        OutputStream os = response.getOutputStream();
        File file = new File("d:\\img\\"+s2);
        FileInputStream fips = new FileInputStream(file);
        ByteArrayOutputStream bops = new ByteArrayOutputStream();
        int data = -1;
        while ((data = fips.read()) != -1) {
            bops.write(data);
        }
        byte[] btImg = bops.toByteArray();
        os.write(btImg);
        os.flush();

    }

 

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM