Package eu.medsea.util
Class ZipJarUtil
- java.lang.Object
-
- eu.medsea.util.ZipJarUtil
-
public class ZipJarUtil extends java.lang.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 java.util.Collection
getEntries(java.io.File file)
Get all entries from a Zip or Jar file.static java.util.Collection
getEntries(java.lang.String fileName)
Get all entries from a Zip or Jar file.static java.util.Collection
getEntries(java.net.URL url)
Get all entries from a Zip or Jar file identified by a URL.static java.util.Collection
getEntries(java.util.zip.ZipFile zipFile)
Get all entries from a zip or jar file.static java.io.InputStream
getInputStreamForURL(java.net.URL url)
Get an InputStream from the zip file capable of reading fromstatic void
main(java.lang.String[] args)
-
-
-
Method Detail
-
getInputStreamForURL
public static java.io.InputStream getInputStreamForURL(java.net.URL url) throws java.io.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:
java.io.IOException
-
getEntries
public static java.util.Collection getEntries(java.lang.String fileName) throws java.util.zip.ZipException, java.io.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:
java.util.zip.ZipException
java.io.IOException
-
getEntries
public static java.util.Collection getEntries(java.io.File file) throws java.util.zip.ZipException, java.io.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:
java.util.zip.ZipException
java.io.IOException
-
getEntries
public static java.util.Collection getEntries(java.net.URL url) throws java.util.zip.ZipException, java.io.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:
java.util.zip.ZipException
java.io.IOException
-
getEntries
public static java.util.Collection getEntries(java.util.zip.ZipFile zipFile) throws java.util.zip.ZipException, java.io.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:
java.util.zip.ZipException
java.io.IOException
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-