get paid to paste

java-zip4j-tut-create-zip-or-add-file-to-zip-2

import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import net.lingala.zip4j.model.ZipParameters;
import java.io.File;
import java.io.IOException;

public class SampleClass{

  public static void main(String[] args)
                     throws ZipException,
                            IOException{
    ZipFile zip = null;
    
    try{
      ZipParameters zp = new ZipParameters();
      zp.setExcludeFileFilter
      (exclude ->; {
        if(exclude.toString().endsWith(".JPEG"))
          return true;
        else return false;
      });
      zip = new ZipFile("myzip.zip");
      zip.addFolder(new File("folder"), zp);
    }
    finally{
      if(zip != null)
        zip.close();
    }
    
    System.out.println("Done!");
  }
}

Pasted: Nov 27, 2024, 11:02:14 am
Views: 9