public IStatus run(IProgressMonitor monitor) throws InvocationTargetException {
  ZipFile zipFile=null;
  FileOutputStream fos=null;
  BufferedOutputStream dest=null;
  BufferedInputStream is=null;
  jobStatus=Status.OK_STATUS;
  try {
    zipFile=new ZipFile(archive);
    monitor.beginTask("Uncompressing " + archive.getName(),zipFile.size());
    Enumeration<? extends ZipEntry> entries=zipFile.entries();
    while (entries.hasMoreElements()) {
      ZipEntry zipEntry=entries.nextElement();
      String currentEntry=zipEntry.getName();
      File destFile=new File(targetDir,currentEntry);
      File destinationParent=destFile.getParentFile();
      if (!zipEntry.isDirectory()) {
        destinationParent.mkdirs();
        is=new BufferedInputStream(zipFile.getInputStream(zipEntry));
        int numBytesRead;
        byte bytes[]=new byte[BUFSIZE];
        fos=new FileOutputStream(destFile);
        dest=new BufferedOutputStream(fos,BUFSIZE);
        while ((numBytesRead=is.read(bytes,0,BUFSIZE)) != -1) {
          dest.write(bytes,0,numBytesRead);
        }
        dest.flush();
      }
 else {
        destFile.mkdirs();
      }
      monitor.worked(1);
      if (monitor.isCanceled()) {
        jobStatus=Status.CANCEL_STATUS;
        break;
      }
    }
    if (!monitor.isCanceled()) {
      jobStatus=Status.OK_STATUS;
    }
  }
 catch (  ZipException ze) {
    String errormsg=errorMessage("It may be corrupted?");
    jobStatus=new Status(Status.ERROR,CorePlugin.PLUGIN_ID,errormsg);
    CorePluginLog.logError(ze,errormsg);
  }
catch (  IOException ioe) {
    String errormsg=errorMessage();
    jobStatus=new Status(Status.ERROR,CorePlugin.PLUGIN_ID,errormsg);
    CorePluginLog.logError(ioe,errormsg);
  }
 finally {
    try {
      if (zipFile != null) {
        zipFile.close();
      }
      if (is != null) {
        is.close();
      }
      if (dest != null) {
        dest.close();
      }
    }
 catch (    IOException ioe) {
      String errormsg=errorMessage();
      jobStatus=new Status(Status.ERROR,CorePlugin.PLUGIN_ID,errormsg);
      CorePluginLog.logError(ioe,errormsg);
    }
  }
  return jobStatus;
}

public IStatus run ( IProgressMonitor monitor ) throws InvocationTargetException { ZipFile zipFile = null ; FileOutputStream fos = null ; BufferedOutputStream dest = null ; BufferedInputStream is = null ; jobStatus = Status . OK_STATUS ; try { zipFile = new ZipFile ( archive ) ; monitor . beginTask ( "Uncompressing " + archive . getName ( ) , zipFile . size ( ) ) ; Enumeration < ? extends ZipEntry > entries = zipFile . entries ( ) ; while ( entries . hasMoreElements ( ) ) { ZipEntry zipEntry = entries . nextElement ( ) ; String currentEntry = zipEntry . getName ( ) ; File destFile = new File ( targetDir , currentEntry ) ; File destinationParent = destFile . getParentFile ( ) ; if ( ! zipEntry . isDirectory ( ) ) { destinationParent . mkdirs ( ) ; is = new BufferedInputStream ( zipFile . getInputStream ( zipEntry ) ) ; int numBytesRead ; byte bytes [ ] = new byte [ BUFSIZE ] ; fos = new FileOutputStream ( destFile ) ; dest = new BufferedOutputStream ( fos , BUFSIZE ) ; while ( ( numBytesRead = is . read ( bytes , 0 , BUFSIZE ) ) != - 1 ) { dest . write ( bytes , 0 , numBytesRead ) ; } dest . flush ( ) ; } else { destFile . mkdirs ( ) ; } monitor . worked ( 1 ) ; if ( monitor . isCanceled ( ) ) { jobStatus = Status . CANCEL_STATUS ; break ; } } if ( ! monitor . isCanceled ( ) ) { jobStatus = Status . OK_STATUS ; } } catch ( ZipException ze ) { String errormsg = errorMessage ( "It may be corrupted?" ) ; jobStatus = new Status ( Status . ERROR , CorePlugin . PLUGIN_ID , errormsg ) ; CorePluginLog . logError ( ze , errormsg ) ; } catch ( IOException ioe ) { String errormsg = errorMessage ( ) ; jobStatus = new Status ( Status . ERROR , CorePlugin . PLUGIN_ID , errormsg ) ; CorePluginLog . logError ( ioe , errormsg ) ; } finally { try { if ( zipFile != null ) { zipFile . close ( ) ; } if ( is != null ) { is . close ( ) ; } if ( dest != null ) { dest . close ( ) ; } } catch ( IOException ioe ) { String errormsg = errorMessage ( ) ; jobStatus = new Status ( Status . ERROR , CorePlugin . PLUGIN_ID , errormsg ) ; CorePluginLog . logError ( ioe , errormsg ) ; } } return jobStatus ; }
executes the unziprunnable using the provided monitor to update the user and provide cancel capabilities .
