이미지 코드 다운로드 및 해독

3104 단어 어지럽다
 1      //       
 2        ServletContext context = this.getServletContext();
 3        //       
 4        String path = context.getRealPath("/imgs/ .jpg");
 5        File file = new File(path);
 6        System.out.println(file);
 7        //                  
 8        response.setHeader("content-disposition", 
 9 "attachment;filename="+
10 URLEncoder.encode(file.getName(),"utf-8")); //                   
11        //          
12        FileInputStream in = new FileInputStream(file);
13        //          
14        ServletOutputStream out = response.getOutputStream();
15        //     
16        byte [] b = new byte[1024];
17        int len = 0;
18        while((len = in.read(b)) != -1){
19            out.write(b, 0, len);
20        }
21        //     
22        in.close();

좋은 웹페이지 즐겨찾기