title: Poor Performance of Java's unzip utilities
body: <p>I have noticed that the unzip facility in Java is extremely slow compared to using a native tool such as WinZip.</p>
  
  <p>Is there a third party library available for Java that is more efficient?
  Open Source is preferred.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Here is a speed comparison using the Java built-in solution vs 7zip.
  I added buffered input/output streams in my original solution (thanks Jim, this did make a big difference).</p>
  
  <p>Zip File size: 800K
  Java Solution: 2.7 seconds
  7Zip solution: 204 ms</p>
  
  <p>Here is the modified code using the built-in Java decompression:</p>
  
  <pre><code>/** Unpacks the give zip file using the built in Java facilities for unzip. */
  @SuppressWarnings("unchecked")
  public final static void unpack(File zipFile, File rootDir) throws IOException
  {
    ZipFile zip = new ZipFile(zipFile);
    Enumeration&lt;ZipEntry&gt; entries = (Enumeration&lt;ZipEntry&gt;) zip.entries();
    while(entries.hasMoreElements()) {
      ZipEntry entry = entries.nextElement();
      java.io.File f = new java.io.File(rootDir, entry.getName());
      if (entry.isDirectory()) { // if its a directory, create it
        continue;
      }
  
      if (!f.exists()) {
        f.getParentFile().mkdirs();
        f.createNewFile();
      }
  
      BufferedInputStream bis = new BufferedInputStream(zip.getInputStream(entry)); // get the input stream
      BufferedOutputStream bos = new BufferedOutputStream(new java.io.FileOutputStream(f));
      while (bis.available() &gt; 0) {  // write contents of 'is' to 'fos'
        bos.write(bis.read());
      }
      bos.close();
      bis.close();
    }
  }
  </code></pre>