eu.medsea.util
Class ZipJarUtil

java.lang.Object
  extended by eu.medsea.util.ZipJarUtil

public class ZipJarUtil
extends Object

Utility class providing methods to work with Zip and Jar Files

Author:
Steven McArdle

Constructor Summary
ZipJarUtil()
           
 
Method Summary
static Collection getEntries(File file)
          Get all entries from a Zip or Jar file.
static Collection getEntries(String fileName)
          Get all entries from a Zip or Jar file.
static Collection getEntries(URL url)
          Get all entries from a Zip or Jar file identified by a URL.
static Collection getEntries(ZipFile zipFile)
          Get all entries from a zip or jar file.
static InputStream getInputStreamForURL(URL url)
          Get an InputStream from the zip file capable of reading from
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipJarUtil

public ZipJarUtil()
Method Detail

getInputStreamForURL

public static InputStream getInputStreamForURL(URL url)
                                        throws IOException
Get an InputStream from the zip file capable of reading from

Parameters:
url -
Returns:
InputStream for reading from a jar or zip file
Throws:
IOException

getEntries

public static Collection getEntries(String fileName)
                             throws ZipException,
                                    IOException
Get all entries from a Zip or Jar file. This defers to the getEntries(ZipFile zipFile) method Example of usage: Collection entries = ZipJarUtil.getEntries("src/test/resources/a.zip");

Parameters:
fileName - path identifying a zip or jar file
Returns:
collection of Strings representing the entries in the zip or jar file
Throws:
ZipException
IOException

getEntries

public static Collection getEntries(File file)
                             throws ZipException,
                                    IOException
Get all entries from a Zip or Jar file. This defers to the getEntries(ZipFile zipFile) method Example of usage: Collection entries = ZipJarUtil.getEntries(new File("src/test/resources/a.zip"));

Parameters:
file - identifies a zip or jar file
Returns:
collection of Strings representing the entries in the zip or jar file
Throws:
ZipException
IOException

getEntries

public static Collection getEntries(URL url)
                             throws ZipException,
                                    IOException
Get all entries from a Zip or Jar file identified by a URL. Example of usage: Collection entries = ZipJarUtil.getEntries(new URL("jar:file:src/test/resources/a.zip!/")); This defers to the getEntries(ZipFile zipFile) method

Parameters:
url - identifying a jar or zip file. Can also refer to an entry, which is ignored.
Returns:
collection of Strings representing the entries in the zip or jar file
Throws:
ZipException
IOException

getEntries

public static Collection getEntries(ZipFile zipFile)
                             throws ZipException,
                                    IOException
Get all entries from a zip or jar file. Ignores directories

Parameters:
zipFile -
Returns:
collection of Strings representing the entries in the zip or jar file
Throws:
ZipException
IOException

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


Copyright © 2007-2010 Medsea Business Solutions S.L.. All Rights Reserved.