1. import net.lingala.zip4j.ZipFile;
  2. import net.lingala.zip4j.exception.ZipException;
  3. import net.lingala.zip4j.model.ZipParameters;
  4. import net.lingala.zip4j.model.enums.EncryptionMethod;
  5. import net.lingala.zip4j.model.enums.AesKeyStrength;
  6. import java.io.File;
  7. import java.io.IOException;
  8. public class SampleClass{
  9. public static void main(String[] args)
  10. throws ZipException,
  11. IOException{
  12. ZipFile zip = null;
  13. try{
  14. zip = new ZipFile
  15. ("myzip.zip", "password".toCharArray());
  16. ZipParameters zp = new ZipParameters();
  17. zp.setEncryptFiles(true);
  18. zp.setEncryptionMethod
  19. (EncryptionMethod.AES);
  20. zp.setAesKeyStrength
  21. (AesKeyStrength.KEY_STRENGTH_256);
  22. zip.createSplitZipFileFromFolder
  23. (new File("folder"), zp, true, 81920);
  24. }
  25. finally{
  26. if(zip != null)
  27. zip.close();
  28. }
  29. System.out.println
  30. ("main thread end");
  31. }
  32. }