1. import net.lingala.zip4j.ZipFile;
  2. import net.lingala.zip4j.exception.ZipException;
  3. import net.lingala.zip4j.model.ZipParameters;
  4. import java.io.File;
  5. import java.io.IOException;
  6. public class SampleClass{
  7. public static void main(String[] args)
  8. throws ZipException,
  9. IOException{
  10. ZipFile zip = null;
  11. try{
  12. ZipParameters zp = new ZipParameters();
  13. zp.setExcludeFileFilter
  14. (exclude ->; {
  15. if(exclude.toString().endsWith(".JPEG"))
  16. return true;
  17. else return false;
  18. });
  19. zip = new ZipFile("myzip.zip");
  20. zip.addFolder(new File("folder"), zp);
  21. }
  22. finally{
  23. if(zip != null)
  24. zip.close();
  25. }
  26. System.out.println("Done!");
  27. }
  28. }