1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
   | response.setContentType("multipart/zip"); 
response.setHeader("Content-Disposition",
                   "attachment; filename=\"" + 
                   filename.trim().substring(1,filename.length()) + "\";"); 
response.setContentLength((int)f.length()); 
 
try
{
      OutputStream os = response.getOutputStream();
      FileInputStream stream = new FileInputStream(f);
      BufferedInputStream  bis = new BufferedInputStream(stream);
      InputStream is = new BufferedInputStream(bis);
      int count;
      byte buf[] = new byte[4096];
      while ((count = is.read(buf)) > -1)
      {
          os.write(buf, 0, count);
      }
      is.close(); 
      os.close();
}
catch (Exception ex)
{ 
   ex.printStackTrace();
}
..
return mapping.findforward("fichieenvoye"); | 
Partager