Package net.ssehub.easy.basics.io
Class JarUtils
java.lang.Object
net.ssehub.easy.basics.io.JarUtils
Some 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 -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReturns whether the givenuriis a Jar URI as returned, e.g., by a classloader.static booleanReturns whether the givenurlis a JAR URL as returned, e.g., by a classloader.static voidUnpacks a Jar file denoted byurlto the giventargetfolder.static voidUnpacks a Jar file denoted byurlto the giventargetfolder.
-
Constructor Details
-
JarUtils
public JarUtils()
-
-
Method Details
-
isJarURI
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
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
Unpacks 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:
MalformedURLException- in case that the URL is ill formed or not a Jar URLIOException- in case of any I/O problems
-
unpackJar
Unpacks 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:
MalformedURLException- in case that the URL is ill formed or not a Jar URLIOException- in case of any I/O problems
-