1. import net.lingala.zip4j.ZipFile;
  2. import net.lingala.zip4j.exception.ZipException;
  3. import net.lingala.zip4j.model.FileHeader;
  4. import java.io.IOException;
  5. public class SampleClass{
  6. public static void main(String[] args)
  7. throws ZipException,
  8. IOException{
  9. ZipFile zip = null;
  10. try{
  11. zip = new ZipFile
  12. ("myzip.zip");
  13. FileHeader header =
  14. zip.getFileHeader("img.jpg");
  15. if(header != null){
  16. zip.removeFile(header);
  17. System.out.println("\"img.jpg\""+
  18. " has been removed.");
  19. }
  20. }
  21. finally{
  22. if(zip != null)
  23. zip.close();
  24. }
  25. }
  26. }