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(); }