private void downloadFileByOutputStream(HttpServletResponse response)
32 throws FileNotFoundException, IOException {
33
34 String realPath = this.getServletContext().getRealPath("/download/1.JPG");
35
36 String fileName = realPath.substring(realPath.lastIndexOf("\\")+1);
37
38 response.setHeader("content-disposition", "attachment;filename="+fileName);
39
40 InputStream in = new FileInputStream(realPath);
41 int len = 0;
42
43 byte[] buffer = new byte[1024];
44
45 OutputStream out = response.getOutputStream();
46
47 while ((len = in.read(buffer)) > 0) {
48
49 out.write(buffer,0,len);
50 }
51 in.close();
52 }