code: public static void zip(File zipFile, final File contents) throws IOException {
  
      OutputStream os = new FileOutputStream(zipFile);
      final ZipOutputStream zs = new ZipOutputStream(os);
  
      try {
        preOrderTraversal(contents, new FileVisitor() {
  
          public boolean visit(File file) throws IOException {
            if (file.isFile()) {
              String name = getRelativePath(file, contents);
              zs.putNextEntry(new ZipEntry(name));
  
              FileInputStream fs = new FileInputStream(file);
              StreamUtil.writeStream(fs, zs);
              fs.close();
  
              zs.closeEntry();
            }
            return true;
          }
  
        });
      } catch (IOException e) {
        throw e;
      } catch (Exception e) {
        throw new UnexpectedException(e);
      }
  
      zs.close();
  
    }
docs: Zips the contents of a directory.
  @param zipFile The <code>File</code> indicating the zip file to create.
  @param contents The <code>File</code> indicating the directory to zip.
  @throws IOException If the contents could not be read or if the zip file
  could not be written.