static void zipDirectory(File sourceDirectory,File zipFile) throws IOException {
  checkNotNull(sourceDirectory);
  checkNotNull(zipFile);
  checkArgument(sourceDirectory.isDirectory(),"%s is not a valid directory",sourceDirectory.getAbsolutePath());
  checkArgument(!zipFile.exists(),"%s does already exist, files are not being overwritten",zipFile.getAbsolutePath());
  Closer closer=Closer.create();
  try {
    OutputStream outputStream=closer.register(new BufferedOutputStream(new FileOutputStream(zipFile)));
    zipDirectory(sourceDirectory,outputStream);
  }
 catch (  Throwable t) {
    throw closer.rethrow(t);
  }
 finally {
    closer.close();
  }
}

static void zipDirectory ( File sourceDirectory , File zipFile ) throws IOException { checkNotNull ( sourceDirectory ) ; checkNotNull ( zipFile ) ; checkArgument ( sourceDirectory . isDirectory ( ) , "%s is not a valid directory" , sourceDirectory . getAbsolutePath ( ) ) ; checkArgument ( ! zipFile . exists ( ) , "%s does already exist, files are not being overwritten" , zipFile . getAbsolutePath ( ) ) ; Closer closer = Closer . create ( ) ; try { OutputStream outputStream = closer . register ( new BufferedOutputStream ( new FileOutputStream ( zipFile ) ) ) ; zipDirectory ( sourceDirectory , outputStream ) ; } catch ( Throwable t ) { throw closer . rethrow ( t ) ; } finally { closer . close ( ) ; } }
zips an entire directory specified by the path .
