Class ZipJarUtil


  • public class ZipJarUtil
    extends Object
    Utility class providing methods to work with Zip and Jar Files
    • 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