1. import net.lingala.zip4j.ZipFile;
  2. import net.lingala.zip4j.exception.ZipException;
  3. public class SampleClass{
  4. public static void main(String[] args)
  5. throws ZipException{
  6. ZipFile zip = null;
  7. try{
  8. zip = new ZipFile("myzip.zip");
  9. zip.addFile("img1.jpg");
  10. zip.addFile("img2.jpg");
  11. }
  12. finally{
  13. if(zip != null)
  14. zip.close();
  15. }
  16. System.out.println
  17. ("myzip.zip has been created!");
  18. }
  19. }