View Javadoc

1   package com.atlassian.plugin.util.zip;
2   
3   import java.io.File;
4   import java.io.IOException;
5   import java.net.URL;
6   import java.util.zip.ZipEntry;
7   import java.util.zip.ZipInputStream;
8   
9   import org.apache.commons.io.IOUtils;
10  
11  public class UrlUnzipper extends AbstractUnzipper
12  {
13      private URL zipUrl;
14  
15      public UrlUnzipper(URL zipUrl, File destDir)
16      {
17          this.zipUrl = zipUrl;
18          this.destDir = destDir;
19      }
20  
21      public void unzip() throws IOException
22      {
23          ZipInputStream zis = null;
24          try
25          {
26              zis = new ZipInputStream(zipUrl.openStream());
27  
28              ZipEntry zipEntry;
29              while ((zipEntry = zis.getNextEntry()) != null)
30              {
31                  saveEntry(zis, zipEntry);
32              }
33          }
34          finally
35          {
36              IOUtils.closeQuietly(zis);
37          }
38      }
39  
40      public File unzipFileInArchive(String fileName) throws IOException
41      {
42          throw new UnsupportedOperationException("Feature not implemented.");
43      }
44  
45      public ZipEntry[] entries() throws IOException
46      {
47          return entries(new ZipInputStream(zipUrl.openStream()));
48      }
49  }