Class JarUtils
- java.lang.Object
-
- org.jboss.util.file.JarUtils
-
public final class JarUtils extends java.lang.ObjectA utility class for dealing with Jar files.- Version:
- $Revision$
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classJarUtils.JarInfoThis simple convenience class is used by the jar method to reduce the number of arguments needed.
-
Constructor Summary
Constructors Modifier Constructor Description privateJarUtils()Hide the constructor
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.net.URLextractNestedJar(java.net.URL jarURL, java.io.File dest)Given a URL check if its a jar url(jar:!/archive) and if it is, extract the archive entry into the given dest directory and return a file URL to its location. private static voidjar(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 voidjar(java.io.OutputStream out, java.io.File src)This function will create a Jar archive containing the src file/directory.static voidjar(java.io.OutputStream out, java.io.File[] src)This function will create a Jar archive containing the src file/directory.static voidjar(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 voidjar(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 voidmain(java.lang.String[] args)static voidunjar(java.io.InputStream in, java.io.File dest)
-
-
-
Method Detail
-
jar
public static void jar(java.io.OutputStream out, java.io.File src) throws java.io.IOExceptionThis 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);- Parameters:
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.- Throws:
java.io.IOException
-
jar
public static void jar(java.io.OutputStream out, java.io.File[] src) throws java.io.IOExceptionThis 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);- Parameters:
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.- Throws:
java.io.IOException
-
jar
public static void jar(java.io.OutputStream out, java.io.File[] src, java.io.FileFilter filter) throws java.io.IOExceptionThis 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);- Parameters:
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.- Throws:
java.io.IOException
-
jar
public 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.IOExceptionThis 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.
- Parameters:
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.- Throws:
java.io.IOException
-
jar
private static void jar(java.io.File src, java.lang.String prefix, JarUtils.JarInfo info) throws java.io.IOExceptionThis recursive method writes all matching files and directories to the jar output stream.- Throws:
java.io.IOException
-
unjar
public static void unjar(java.io.InputStream in, java.io.File dest) throws java.io.IOException- Throws:
java.io.IOException
-
extractNestedJar
public static java.net.URL extractNestedJar(java.net.URL jarURL, java.io.File dest) throws java.io.IOExceptionGiven a URL check if its a jar url(jar:!/archive) and if it is, extract the archive entry into the given dest directory and return a file URL to its location. If jarURL is not a jar url then it is simply returned as the URL for the jar. - Parameters:
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.- Returns:
- the file: URL for the jar referenced by the jarURL parameter.
- Throws:
java.io.IOException
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception- Throws:
java.lang.Exception
-
-