title: Compress directory into a zipfile with Commons IO
body: <p>I am a beginner at programming with Java and am currently writing an application which must be able to compress and decompress <code>.zip</code> files.  I can use the following code to decompress a zipfile in Java using the built-in Java zip functionality as well as the Apache Commons IO library:</p>
  
  <pre><code>public static void decompressZipfile(String file, String outputDir) throws IOException {
      if (!new File(outputDir).exists()) {
          new File(outputDir).mkdirs();
      }
      ZipFile zipFile = new ZipFile(file);
      Enumeration&lt;? extends ZipEntry&gt; entries = zipFile.entries();
      while (entries.hasMoreElements()) {
          ZipEntry entry = entries.nextElement();
          File entryDestination = new File(outputDir, entry.getName());
          if (entry.isDirectory()) {
              entryDestination.mkdirs();
          } else {
              InputStream in = zipFile.getInputStream(entry);
              OutputStream out = new FileOutputStream(entryDestination);
              IOUtils.copy(in, out);
              IOUtils.closeQuietly(in);
              IOUtils.closeQuietly(out);
          }
      }
  }
  </code></pre>
  
  <p>How would I go about creating a zipfile from a directory using no external libraries other than what I am already using? (Java standard libraries and Commons IO)</p>