Class JarUtils


  • public final class JarUtils
    extends Object
    Some utility classes for manipulating JAR files.
    • Constructor Detail

      • JarUtils

        public JarUtils()
    • Method Detail

      • createJarFromDirectory

        protected void createJarFromDirectory​(File root,
                                              File directory,
                                              JarOutputStream jarStream)
                                       throws IOException
        Create a jar file from a particular directory.
        Parameters:
        root - in the root directory
        directory - in the directory we are adding
        jarStream - the jar stream to be added to
        Throws:
        IOException - on IOException
      • createJarFromDirectory

        public File createJarFromDirectory​(String directory,
                                           File outputJar)
                                    throws IOException
        Create a JAR file from a directory, recursing through children.
        Parameters:
        directory - in directory source
        outputJar - in file to output the jar data to
        Returns:
        out File that was generated
        Throws:
        IOException - when there is an I/O exception
      • containsClass

        public boolean containsClass​(String jarFile,
                                     String classToBeFound)
                              throws IOException
        Search through JAR file to check if it contains specified class.
        Parameters:
        jarFile - JAR file to be searched.
        classToBeFound - Class which we look for (including package).
        Returns:
        True if JAR file contains specified class.
        Throws:
        IOException - when there is an I/O exception