Advertisement
Guest User

Untitled

a guest
Jul 25th, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. byte[] buffer = new byte[1024];
  2.  
  3. try{
  4.  
  5. FileOutputStream fos = new FileOutputStream("C:\MyFile.zip");
  6. ZipOutputStream zos = new ZipOutputStream(fos);
  7. ZipEntry ze= new ZipEntry("spy.log");
  8. zos.putNextEntry(ze);
  9. FileInputStream in = new FileInputStream("C:\spy.log");
  10.  
  11. int len;
  12. while ((len = in.read(buffer)) > 0) {
  13. zos.write(buffer, 0, len);
  14. }
  15.  
  16. in.close();
  17. zos.closeEntry();
  18.  
  19. //remember close it
  20. zos.close();
  21.  
  22. System.out.println("Done");
  23.  
  24. }catch(IOException ex){
  25. ex.printStackTrace();
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement