类 JarUtils

    • 构造器概要

      构造器 
      构造器 说明
      JarUtils()  
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      protected static void assertJarURLProtocol​(java.net.URL jarURL)
      Assert jarURL argument is valid , only supported protocols : jar and file
      protected static void doExtract​(java.util.jar.JarFile jarFile, java.lang.Iterable<java.util.jar.JarEntry> jarEntries, java.io.File targetDirectory)  
      protected static java.util.List<java.util.jar.JarEntry> doFilter​(java.lang.Iterable<java.util.jar.JarEntry> jarEntries, JarEntryFilter jarEntryFilter)  
      static void extract​(java.io.File jarSourceFile, java.io.File targetDirectory)
      Extract the source JarFile to target directory
      static void extract​(java.io.File jarSourceFile, java.io.File targetDirectory, JarEntryFilter jarEntryFilter)
      Extract the source JarFile to target directory with specified JarEntryFilter
      static void extract​(java.net.URL jarResourceURL, java.io.File targetDirectory, JarEntryFilter jarEntryFilter)
      Extract the source JarFile to target directory with specified JarEntryFilter
      static void extract​(java.util.jar.JarFile jarFile, java.io.File targetDirectory, JarEntryFilter jarEntryFilter)
      Extract the source JarFile to target directory with specified JarEntryFilter
      static java.util.List<java.util.jar.JarEntry> filter​(java.util.jar.JarFile jarFile, JarEntryFilter jarEntryFilter)
      Filter JarEntry list from JarFile
      static java.util.jar.JarEntry findJarEntry​(java.net.URL jarURL)
      Find JarEntry from specified url
      static java.lang.String resolveJarAbsolutePath​(java.net.URL jarURL)
      Resolve absolute path from the URL of JarEntry
      static java.lang.String resolveRelativePath​(java.net.URL jarURL)
      Resolve Relative path from Jar URL
      static java.util.jar.JarFile toJarFile​(java.net.URL jarURL)
      Create a JarFile from specified URL of JarFile
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • JarUtils

        public JarUtils()
    • 方法详细资料

      • toJarFile

        public static java.util.jar.JarFile toJarFile​(java.net.URL jarURL)
                                               throws java.io.IOException
        Create a JarFile from specified URL of JarFile
        参数:
        jarURL - URL of JarFile or JarEntry
        返回:
        JarFile
        抛出:
        java.io.IOException - If jar file is invalid, see JarFile(String)
        从以下版本开始:
        1.0.0
      • assertJarURLProtocol

        protected static void assertJarURLProtocol​(java.net.URL jarURL)
                                            throws java.lang.NullPointerException,
                                                   java.lang.IllegalArgumentException
        Assert jarURL argument is valid , only supported protocols : jar and file
        参数:
        jarURL - URL of JarFile or JarEntry
        抛出:
        java.lang.NullPointerException - If jarURL is null
        java.lang.IllegalArgumentException - If URL.getProtocol() is not jar or file
      • resolveRelativePath

        @Nonnull
        public static java.lang.String resolveRelativePath​(java.net.URL jarURL)
                                                    throws java.lang.NullPointerException,
                                                           java.lang.IllegalArgumentException
        Resolve Relative path from Jar URL
        参数:
        jarURL - URL of JarFile or JarEntry
        返回:
        Non-null
        抛出:
        java.lang.NullPointerException - see assertJarURLProtocol(URL)
        java.lang.IllegalArgumentException - see assertJarURLProtocol(URL)
      • resolveJarAbsolutePath

        @Nonnull
        public static java.lang.String resolveJarAbsolutePath​(java.net.URL jarURL)
                                                       throws java.lang.NullPointerException,
                                                              java.lang.IllegalArgumentException
        Resolve absolute path from the URL of JarEntry
        参数:
        jarURL - URL of JarFile or JarEntry
        返回:
        If URL.getProtocol() equals jar or file , resolves absolute path, or return null
        抛出:
        java.lang.NullPointerException - see assertJarURLProtocol(URL)
        java.lang.IllegalArgumentException - see assertJarURLProtocol(URL)
        从以下版本开始:
        1.0.0
      • filter

        @Nonnull
        public static java.util.List<java.util.jar.JarEntry> filter​(java.util.jar.JarFile jarFile,
                                                                    JarEntryFilter jarEntryFilter)
        Filter JarEntry list from JarFile
        参数:
        jarFile - JarFile
        jarEntryFilter - JarEntryFilter
        返回:
        Read-only List
      • doFilter

        protected static java.util.List<java.util.jar.JarEntry> doFilter​(java.lang.Iterable<java.util.jar.JarEntry> jarEntries,
                                                                         JarEntryFilter jarEntryFilter)
      • findJarEntry

        public static java.util.jar.JarEntry findJarEntry​(java.net.URL jarURL)
                                                   throws java.io.IOException
        Find JarEntry from specified url
        参数:
        jarURL - jar resource url
        返回:
        If found , return JarEntry
        抛出:
        java.io.IOException
      • extract

        public static void extract​(java.io.File jarSourceFile,
                                   java.io.File targetDirectory)
                            throws java.io.IOException
        Extract the source JarFile to target directory
        参数:
        jarSourceFile - the source JarFile
        targetDirectory - target directory
        抛出:
        java.io.IOException - When the source jar file is an invalid JarFile
      • extract

        public static void extract​(java.io.File jarSourceFile,
                                   java.io.File targetDirectory,
                                   JarEntryFilter jarEntryFilter)
                            throws java.io.IOException
        Extract the source JarFile to target directory with specified JarEntryFilter
        参数:
        jarSourceFile - the source JarFile
        targetDirectory - target directory
        jarEntryFilter - JarEntryFilter
        抛出:
        java.io.IOException - When the source jar file is an invalid JarFile
      • extract

        public static void extract​(java.util.jar.JarFile jarFile,
                                   java.io.File targetDirectory,
                                   JarEntryFilter jarEntryFilter)
                            throws java.io.IOException
        Extract the source JarFile to target directory with specified JarEntryFilter
        参数:
        jarFile - the source JarFile
        targetDirectory - target directory
        jarEntryFilter - JarEntryFilter
        抛出:
        java.io.IOException - When the source jar file is an invalid JarFile
      • extract

        public static void extract​(java.net.URL jarResourceURL,
                                   java.io.File targetDirectory,
                                   JarEntryFilter jarEntryFilter)
                            throws java.io.IOException
        Extract the source JarFile to target directory with specified JarEntryFilter
        参数:
        jarResourceURL - The resource URL of JarFile or JarEntry
        targetDirectory - target directory
        jarEntryFilter - JarEntryFilter
        抛出:
        java.io.IOException - When the source jar file is an invalid JarFile
      • doExtract

        protected static void doExtract​(java.util.jar.JarFile jarFile,
                                        java.lang.Iterable<java.util.jar.JarEntry> jarEntries,
                                        java.io.File targetDirectory)
                                 throws java.io.IOException
        抛出:
        java.io.IOException