1. import net.lingala.zip4j.ZipFile;
  2. import net.lingala.zip4j.exception.ZipException;
  3. import java.io.IOException;
  4. public class SampleClass{
  5. public static void main(String[] args)
  6. throws ZipException,
  7. IOException{
  8. ZipFile zip = null;
  9. try{
  10. zip = new ZipFile
  11. ("myzip.zip");
  12. //remove a file
  13. zip.removeFile("img.jpg");
  14. //remove a directory (since v2.5.0 of Zip4j)
  15. zip.removeFile("folder/folderA/");
  16. }
  17. finally{
  18. if(zip != null)
  19. zip.close();
  20. }
  21. System.out.println("main thread end.");
  22. }
  23. }