日期:2014-05-17 浏览次数:20892 次
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html; charset=GBK"); response.setContentType("image/jpeg"); FileInputStream fis = new FileInputStream("C:/xxx.jpg"); OutputStream os = response.getOutputStream(); try { int count = 0; byte[] buffer = new byte[1024*8]; while ( (count = fis.read(buffer)) != -1 ) os.write(buffer, 0, count); } finally { fis.close(); os.close(); } }