com.neeve.util
Class UtlJar

java.lang.Object
  extended by com.neeve.util.UtlJar

public class UtlJar
extends Object

Utilities for working with jar files.

This class MAY be used by end users, however it is not supported.


Constructor Summary
UtlJar()
           
 
Method Summary
static void extractClasspathToDirectory(ClassLoader loader, File outputDir)
          Extracts the current classpath to the given folder as loose files.
static void extractFolder(URL jarUrl, String folderName, File targetFolder)
          Extract a folder from a jar.
static void jar(File source, File target)
          Jars the given directory.
static void listFiles(URL jarFolderUrl, Set<URL> results, UtlResource.URLFilter filter)
          From a jar url of jar:[jar-path.jar]!
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UtlJar

public UtlJar()
Method Detail

extractFolder

public static void extractFolder(URL jarUrl,
                                 String folderName,
                                 File targetFolder)
                          throws IOException
Extract a folder from a jar.

If the target folder does not exist, it and any subdirectories will be created as needed. Existing files in the target folder that are extracted will be overwritten, but other files already in the target folder path will be preserved.

Parameters:
jarUrl - The location of the jar.
folderName - The folder name in the jar that should be extracted.
targetFolder - The target directory to which to extract.
Throws:
IOException - If there is an I/O error extracting from the jar.

extractClasspathToDirectory

public static final void extractClasspathToDirectory(ClassLoader loader,
                                                     File outputDir)
                                              throws IOException
Extracts the current classpath to the given folder as loose files.

Parameters:
loader - The ClassLoader from which to extract class files.
outputDir - The target directory
Throws:
IOException - If there is an error extracting the classpath.
IllegalArgumentException - If the ClassLoader type is not supported.

jar

public static final void jar(File source,
                             File target)
                      throws IOException
Jars the given directory.

Parameters:
source - The source directory.
target - The target jar file.
Throws:
IOException - If there is an error creating the jar.

listFiles

public static void listFiles(URL jarFolderUrl,
                             Set<URL> results,
                             UtlResource.URLFilter filter)
                      throws IOException
From a jar url of jar:[jar-path.jar]!/[folderPath], this method will return jar entries that are immediate children of the specified folder that are not them selves folders. If folderPath portion has not children, no URLs are added to the results.

Parameters:
jarFolderUrl - The url of the jar including the folder name in which to look.
results - The set into which to place the listed files.
filter - An optional filter that can be used to filter files from being added to the results
Throws:
IOException - If there is an error listing the files in the jar.


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.