public abstract class ResourceUtils
extends java.lang.Object
| 限定符和类型 | 字段和说明 |
|---|---|
static java.lang.String |
CLASSPATH_URL_PREFIX
Pseudo URL prefix for loading from the class path: "classpath:"
|
static java.lang.String |
FILE_URL_PREFIX
URL prefix for loading from the file system: "file:"
|
static java.lang.String |
JAR_URL_SEPARATOR
Separator between JAR URL and file path within the JAR
|
static java.lang.String |
PREFIX_SEPARATOR |
static java.lang.String |
URL_PROTOCOL_FILE
URL protocol for a file in the file system: "file"
|
static java.lang.String |
URL_PROTOCOL_JAR
URL protocol for an entry from a jar file: "jar"
|
static java.lang.String |
URL_PROTOCOL_ZIP
URL protocol for an entry from a zip file: "zip"
|
| 构造器和说明 |
|---|
ResourceUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static java.net.URL |
extractJarFileURL(java.net.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 java.io.File |
getFile(java.lang.String resourceLocation)
Resolve the given resource location to a
java.io.File, i.e. |
static java.io.File |
getFile(java.net.URI resourceUri)
Resolve the given resource URI to a
java.io.File, i.e. to a
file in the file system. |
static java.io.File |
getFile(java.net.URL resourceUrl)
Resolve the given resource URL to a
java.io.File, i.e. to a
file in the file system. |
static java.net.URL |
getURL(java.lang.String resourceLocation)
Resolve the given resource location to a
java.net.URL. |
static boolean |
isJarURL(java.net.URL url)
Determine whether the given URL points to a resource in a jar file, that
is, has protocol "jar", "zip".
|
static boolean |
isUrl(java.lang.String resourceLocation)
Return whether the given resource location is a URL: either a special
"classpath" pseudo URL or a standard URL.
|
static java.net.URI |
toURI(java.lang.String location)
Create a URI instance for the given location String, replacing spaces
with "%20" quotes first.
|
static java.net.URI |
toURI(java.net.URL url)
Create a URI instance for the given URL, replacing spaces with "%20"
quotes first.
|
public static final java.lang.String PREFIX_SEPARATOR
public static final java.lang.String CLASSPATH_URL_PREFIX
public static final java.lang.String FILE_URL_PREFIX
public static final java.lang.String URL_PROTOCOL_FILE
public static final java.lang.String URL_PROTOCOL_JAR
public static final java.lang.String URL_PROTOCOL_ZIP
public static final java.lang.String JAR_URL_SEPARATOR
public static java.net.URL getURL(java.lang.String resourceLocation)
throws java.io.FileNotFoundException
java.net.URL.
Does not check whether the URL actually exists; simply returns the URL that the given location would correspond to.
resourceLocation - the resource location to resolve: either a "classpath:" pseudo
URL, a "file:" URL, or a plain file pathjava.io.FileNotFoundException - if the resource cannot be resolved to a URLpublic static java.io.File getFile(java.lang.String resourceLocation)
throws java.io.FileNotFoundException
java.io.File, i.e.
to a file in the file system.
Does not check whether the file actually exists; simply returns the File that the given location would correspond to.
resourceLocation - the resource location to resolve: either a "classpath:" pseudo
URL, a "file:" URL, or a plain file pathjava.io.FileNotFoundException - if the resource cannot be resolved to a file in the file
systempublic static java.io.File getFile(java.net.URL resourceUrl)
throws java.io.FileNotFoundException
java.io.File, i.e. to a
file in the file system.resourceUrl - the resource URL to resolvejava.io.FileNotFoundException - if the URL cannot be resolved to a file in the file systempublic static java.io.File getFile(java.net.URI resourceUri)
throws java.io.FileNotFoundException
java.io.File, i.e. to a
file in the file system.resourceUri - the resource URI to resolvejava.io.FileNotFoundException - if the URL cannot be resolved to a file in the file systempublic static boolean isUrl(java.lang.String resourceLocation)
resourceLocation - the location String to checkpublic static boolean isJarURL(java.net.URL url)
url - the URL to checkpublic static java.net.URL extractJarFileURL(java.net.URL jarUrl)
throws java.net.MalformedURLException
jarUrl - the original URLjava.net.MalformedURLException - if no valid jar file URL could be extractedpublic static java.net.URI toURI(java.net.URL url)
throws java.net.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 instancejava.net.URISyntaxException - if the URL wasn't a valid URIpublic static java.net.URI toURI(java.lang.String location)
throws java.net.URISyntaxException
location - the location String to convert into a URI instancejava.net.URISyntaxException - if the location wasn't a valid URICopyright © 2024. All Rights Reserved.