code: public void extract() throws IOException, InterruptedException {
  
      try {
        extractorProvider.extract(archive, destination, progressListener);
      } catch (IOException ex) {
        try {
          logger.warning("Extraction failed, cleaning up " + destination);
          cleanUp(destination);
        } catch (IOException exx) {
          logger.warning("Failed to cleanup directory");
        }
        // intentional rethrow after cleanup
        throw ex;
      }
  
      // we do not allow interrupt mid extraction, so catch it here, we still end up
      // with a valid directory though, so don't clean it up.
      if (Thread.currentThread().isInterrupted()) {
        logger.warning("Process was interrupted");
        throw new InterruptedException("Process was interrupted");
      }
    }
docs: Extract an archive.