public final class JarUtils
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
JarUtils.JarInfo
This simple convenience class is used by the jar method to reduce the
number of arguments needed.
|
| Modifier | Constructor and Description |
|---|---|
private |
JarUtils()
Hide the constructor
|
| Modifier and Type | Method and Description |
|---|---|
static java.net.URL |
extractNestedJar(java.net.URL jarURL,
java.io.File dest)
Given a URL check if its a jar url(jar:
|
private static void |
jar(java.io.File src,
java.lang.String prefix,
JarUtils.JarInfo info)
This recursive method writes all matching files and directories to
the jar output stream.
|
static void |
jar(java.io.OutputStream out,
java.io.File src)
This function will create a Jar archive containing the src
file/directory.
|
static void |
jar(java.io.OutputStream out,
java.io.File[] src)
This function will create a Jar archive containing the src
file/directory.
|
static void |
jar(java.io.OutputStream out,
java.io.File[] src,
java.io.FileFilter filter)
This function will create a Jar archive containing the src
file/directory.
|
static void |
jar(java.io.OutputStream out,
java.io.File[] src,
java.io.FileFilter filter,
java.lang.String prefix,
java.util.jar.Manifest man)
This function will create a Jar archive containing the src
file/directory.
|
static void |
main(java.lang.String[] args) |
static void |
unjar(java.io.InputStream in,
java.io.File dest) |
public static void jar(java.io.OutputStream out,
java.io.File src)
throws java.io.IOException
This function will create a Jar archive containing the src file/directory. The archive will be written to the specified OutputStream.
This is a shortcut for
jar(out, new File[] { src }, null, null, null);
out - The output stream to which the generated Jar archive is
written.src - The file or directory to jar up. Directories will be
processed recursively.java.io.IOExceptionpublic static void jar(java.io.OutputStream out,
java.io.File[] src)
throws java.io.IOException
This function will create a Jar archive containing the src file/directory. The archive will be written to the specified OutputStream.
This is a shortcut for
jar(out, src, null, null, null);
out - The output stream to which the generated Jar archive is
written.src - The file or directory to jar up. Directories will be
processed recursively.java.io.IOExceptionpublic static void jar(java.io.OutputStream out,
java.io.File[] src,
java.io.FileFilter filter)
throws java.io.IOException
This function will create a Jar archive containing the src file/directory. The archive will be written to the specified OutputStream. Directories are processed recursively, applying the specified filter if it exists.
This is a shortcut for
jar(out, src, filter, null, null);
out - The output stream to which the generated Jar archive is
written.src - The file or directory to jar up. Directories will be
processed recursively.filter - The filter to use while processing directories. Only
those files matching will be included in the jar archive. If
null, then all files are included.java.io.IOExceptionpublic static void jar(java.io.OutputStream out,
java.io.File[] src,
java.io.FileFilter filter,
java.lang.String prefix,
java.util.jar.Manifest man)
throws java.io.IOException
This function will create a Jar archive containing the src file/directory. The archive will be written to the specified OutputStream. Directories are processed recursively, applying the specified filter if it exists.
out - The output stream to which the generated Jar archive is
written.src - The file or directory to jar up. Directories will be
processed recursively.filter - The filter to use while processing directories. Only
those files matching will be included in the jar archive. If
null, then all files are included.prefix - The name of an arbitrary directory that will precede all
entries in the jar archive. If null, then no prefix will be
used.man - The manifest to use for the Jar archive. If null, then no
manifest will be included.java.io.IOExceptionprivate static void jar(java.io.File src,
java.lang.String prefix,
JarUtils.JarInfo info)
throws java.io.IOException
java.io.IOExceptionpublic static void unjar(java.io.InputStream in,
java.io.File dest)
throws java.io.IOException
java.io.IOExceptionpublic static java.net.URL extractNestedJar(java.net.URL jarURL,
java.io.File dest)
throws java.io.IOException
jarURL - the URL to validate and extract the referenced entry if its
a jar protocol URLdest - the directory into which the nested jar will be extracted.java.io.IOExceptionpublic static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception