hmi.util
Class UnJar

java.lang.Object
  extended by hmi.util.UnJar

public final class UnJar
extends Object

UnJar extracts files from a jar file

Author:
Job Zwiers

Field Summary
private static int BUFSIZE
           
private static int DIALOGHEIGHT
           
private static int DIALOGWIDTH
           
 
Constructor Summary
private UnJar()
           
 
Method Summary
static List<String> autoExtract(String regex, String extractDirectory, boolean listOnly, boolean overwrite)
          Extracts files, assuming that this UnJar class is running from the same jar file that contains the files to be extracted.
static List<String> extract(Class<?> cl, String regex, String extractDirectory, boolean listOnly, boolean overwrite)
          Like extract(jar, regex, extractDirectory) where the jar file is located by means of UnJar.getJarFromClass(cl)
static List<String> extract(File jarfile, String regex, File extractDir)
          Extracts files with names that match the specified regular expression from a jar File, and puts the result in a specified directory.
static List<String> extract(File jarfile, String regex, File extractDir, boolean listOnly, boolean overwrite)
          Extracts files with names that match the specified regular expression from a jar File, and puts the result in a specified directory.
static List<String> extract(String jar, String regex, String extractDirectory)
          Extracts files with names that match the specified regular expression from a named jar file.
static List<String> extract(String jar, String regex, String extractDirectory, boolean listOnly, boolean overwrite)
          Extracts files with names that match the specified regular expression from a named jar file.
private static void extractJarEntry(JarFile jarFile, JarEntry jarEntry, File outputFile)
           
static String getCodeSourceLocation()
           
static String getJarForClass(Class<?> cl)
          Return a String with the codesouce location of the specified Class.
static List<String> list(String jar, String regex, String extractDirectory)
          Lists files with names that match the specified regular expression from a named jar file.
static void main(String[] arg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIALOGWIDTH

private static final int DIALOGWIDTH
See Also:
Constant Field Values

DIALOGHEIGHT

private static final int DIALOGHEIGHT
See Also:
Constant Field Values

BUFSIZE

private static final int BUFSIZE
See Also:
Constant Field Values
Constructor Detail

UnJar

private UnJar()
Method Detail

getJarForClass

public static String getJarForClass(Class<?> cl)
Return a String with the codesouce location of the specified Class. This could denote some jar file, or some directory like ..../classes


autoExtract

public static List<String> autoExtract(String regex,
                                       String extractDirectory,
                                       boolean listOnly,
                                       boolean overwrite)
Extracts files, assuming that this UnJar class is running from the same jar file that contains the files to be extracted. The regular expression specifies which files to extract.


extract

public static List<String> extract(Class<?> cl,
                                   String regex,
                                   String extractDirectory,
                                   boolean listOnly,
                                   boolean overwrite)
Like extract(jar, regex, extractDirectory) where the jar file is located by means of UnJar.getJarFromClass(cl)


extract

public static List<String> extract(String jar,
                                   String regex,
                                   String extractDirectory)
Extracts files with names that match the specified regular expression from a named jar file. Extracted files are placed in the specified directory. The latter must exist already. If extracted files have some non-trivial path, subdirectories will be created as necessary. files are not automaticaly overwritten.


list

public static List<String> list(String jar,
                                String regex,
                                String extractDirectory)
Lists files with names that match the specified regular expression from a named jar file. The extractDirectory path is prepended, just like it is done for the UnJar.extract operations. Note that all matching files are included, like the result for an extract operation with overwrite equal to true.


extract

public static List<String> extract(String jar,
                                   String regex,
                                   String extractDirectory,
                                   boolean listOnly,
                                   boolean overwrite)
Extracts files with names that match the specified regular expression from a named jar file. Extracted files are placed in the specified directory. The latter must exist already. If extracted files have some non-trivial path, subdirectories will be created as necessary.


extract

public static List<String> extract(File jarfile,
                                   String regex,
                                   File extractDir)
Extracts files with names that match the specified regular expression from a jar File, and puts the result in a specified directory. The latter must exist already. If extracted files have some non-trivial path, subdirectories will be created as necessary.


extract

public static List<String> extract(File jarfile,
                                   String regex,
                                   File extractDir,
                                   boolean listOnly,
                                   boolean overwrite)
Extracts files with names that match the specified regular expression from a jar File, and puts the result in a specified directory. The latter must exist already. If extracted files have some non-trivial path, subdirectories will be created as necessary. When listOnly is true, files are added to the List returned, but no actual file extraction is done. When overwrite is true, files are unconditionally extracted (or listed). When overwrite is false, then existing files are overwritten only when they differ in size and/or timestamp. Moreover, a popup panel asks for permission to overwrite in these cases.


extractJarEntry

private static void extractJarEntry(JarFile jarFile,
                                    JarEntry jarEntry,
                                    File outputFile)

getCodeSourceLocation

public static String getCodeSourceLocation()

main

public static void main(String[] arg)