Posted By

indianocean on 11/13/06


Tagged

zip


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

bobmin
rtipton


ZIP and Stream Files


 / Published in: Java
 

  1. // ZIP Stream
  2. ZipOutputStream slipStream = new ZipOutputStream(response.getOutputStream());
  3. slipStream.setEncoding("CP437");
  4. slipStream.setLevel(Deflater.BEST_COMPRESSION);
  5.  
  6. ZipEntry fcst = new ZipEntry("Forecast-" + year + ".xls");
  7. slipStream.putNextEntry(fcst);
  8. wbForecast.write(ausgabeProtokoll);
  9. slipStream.write(ausgabeProtokoll.toByteArray());
  10. slipStream.closeEntry();
  11.  
  12. // Protokoll in ZIP
  13. ZipEntry protokoll = new ZipEntry("protokoll" + ".xls");
  14. slipStream.putNextEntry(protokoll);
  15. wbProtokoll.write(ausgabeForecast);
  16. slipStream.write(ausgabeForecast.toByteArray());
  17. slipStream.closeEntry();
  18.  
  19. slipStream.close();
  20.  
  21. response.setContentType("application/zip");
  22. response.setHeader("Content-Disposition", "Attachment; filename=\"" + "Forecast-" + year + ".zip" + "\"");

Report this snippet  

You need to login to post a comment.