Package eu.medsea.util
Class ZipJarUtil
- java.lang.Object
-
- eu.medsea.util.ZipJarUtil
-
public class ZipJarUtil extends Object
Utility class providing methods to work with Zip and Jar Files
-
-
Constructor Summary
Constructors Constructor Description ZipJarUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static CollectiongetEntries(File file)Get all entries from a Zip or Jar file.static CollectiongetEntries(String fileName)Get all entries from a Zip or Jar file.static CollectiongetEntries(URL url)Get all entries from a Zip or Jar file identified by a URL.static CollectiongetEntries(ZipFile zipFile)Get all entries from a zip or jar file.static InputStreamgetInputStreamForURL(URL url)Get an InputStream from the zip file capable of reading fromstatic voidmain(String[] args)
-
-
-
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:
ZipExceptionIOException
-
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:
ZipExceptionIOException
-
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:
ZipExceptionIOException
-
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:
ZipExceptionIOException
-
-