public abstract class ResourceUtils extends Object
| Constructor and Description |
|---|
ResourceUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
extractJarEntryPath(URL jarUrl)
Extract the JAR entry from the given URL
|
static URL |
extractJarFileURL(URL jarUrl)
Extract the URL for the actual jar file from the given URL
(which may point to a resource in a jar file or to a jar file itself).
|
static File |
getFile(URL resourceUrl)
Resolve the given resource URL to a
java.io.File,
i.e. |
static File |
getFile(URL resourceUrl,
org.zeroturnaround.javarebel.RebelServletContext sc)
Resolve the given resource URL to a
java.io.File,
i.e. |
static File |
getFile(URL resourceUrl,
String description)
Resolve the given resource URL to a
java.io.File,
i.e. |
static boolean |
isFileURL(URL url)
Determine whether the given URL points to a resource in the file system.
|
static boolean |
isJarURL(URL url)
Determine whether the given URL points to a resource in a jar file,
that is, has protocol "jar", "zip", "wsjar" or "code-source".
|
static boolean |
isUrl(String s)
Determines if the parameter is a URL with a protocol or not
|
static URI |
toURI(String location)
Create a URI instance for the given location String,
replacing spaces with "%20" quotes first.
|
static URI |
toURI(URL url)
Create a URI instance for the given URL,
replacing spaces with "%20" quotes first.
|
public static boolean isUrl(String s)
public static File getFile(URL resourceUrl, org.zeroturnaround.javarebel.RebelServletContext sc)
java.io.File,
i.e. to a file in the file system.resourceUrl - the resource URL to resolveFileNotFoundException - if the URL cannot be resolved to
a file in the file systempublic static File getFile(URL resourceUrl)
java.io.File,
i.e. to a file in the file system.resourceUrl - the resource URL to resolvepublic static File getFile(URL resourceUrl, String description)
java.io.File,
i.e. to a file in the file system.resourceUrl - the resource URL to resolvedescription - a description of the original resource that
the URL was created for (for example, a class path location)public static boolean isFileURL(URL url)
url - the URL to check. May be null.public static boolean isJarURL(URL url)
"zip" and "wsjar" are used by BEA WebLogic Server and IBM WebSphere, respectively, but can be treated like jar files. The same applies to "code-source" URLs on Oracle OC4J, provided that the path contains a jar separator.
url - the URL to check. May be null.public static URL extractJarFileURL(URL jarUrl)
jarUrl - the original URLpublic static String extractJarEntryPath(URL jarUrl)
jarUrl - the original URLpublic static URI toURI(URL url) throws URISyntaxException
Furthermore, this method works on JDK 1.4 as well,
in contrast to the URL.toURI() method.
url - the URL to convert into a URI instanceURISyntaxException - if the URL wasn't a valid URIURL.toURI()public static URI toURI(String location) throws URISyntaxException
location - the location String to convert into a URI instanceURISyntaxException - if the location wasn't a valid URICopyright © 2014. All rights reserved.