Package net.ssehub.easy.basics.io
Class JarUtils
- java.lang.Object
-
- net.ssehub.easy.basics.io.JarUtils
-
public class JarUtils extends java.lang.ObjectSome helpful Jar methods. Could be partially be replaced by JDK 7 FileSystem, but currently this bundle is built for JDK5.- Author:
- Holger Eichelberger
-
-
Constructor Summary
Constructors Constructor Description JarUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisJarURI(java.net.URI uri)Returns whether the givenuriis a Jar URI as returned, e.g., by a classloader.static booleanisJarURL(java.net.URL url)Returns whether the givenurlis a JAR URL as returned, e.g., by a classloader.static voidunpackJar(java.net.URL url, java.io.File target)Unpacks a Jar file denoted byurlto the giventargetfolder.static voidunpackJar(java.net.URL url, java.lang.String resource, java.io.File target)Unpacks a Jar file denoted byurlto the giventargetfolder.
-
-
-
Method Detail
-
isJarURI
public static boolean isJarURI(java.net.URI uri)
Returns whether the givenuriis a Jar URI as returned, e.g., by a classloader.- Parameters:
uri- the URI (ignored if null)- Returns:
truefor a Jar URI,falseelse
-
isJarURL
public static boolean isJarURL(java.net.URL url)
Returns whether the givenurlis a JAR URL as returned, e.g., by a classloader.- Parameters:
url- the URL (ignored if null)- Returns:
truefor a JAR URL,falseelse
-
unpackJar
public static void unpackJar(java.net.URL url, java.io.File target) throws java.net.MalformedURLException, java.io.IOExceptionUnpacks a Jar file denoted byurlto the giventargetfolder.targetmay not exist and is created then. Existing files are overwritten.- Parameters:
url- the Jar URLtarget- the target folder- Throws:
java.net.MalformedURLException- in case that the URL is ill formed or not a Jar URLjava.io.IOException- in case of any I/O problems
-
unpackJar
public static void unpackJar(java.net.URL url, java.lang.String resource, java.io.File target) throws java.io.IOExceptionUnpacks a Jar file denoted byurlto the giventargetfolder.targetmay not exist and is created then. Existing files are overwritten.- Parameters:
url- the Jar URLresource- a resource within the JAR to extract, may be a file or a folder in JAR format specification, i.e., without leading / but trailing /target- the target folder- Throws:
java.net.MalformedURLException- in case that the URL is ill formed or not a Jar URLjava.io.IOException- in case of any I/O problems
-
-