public class ResourceUtils
extends java.lang.Object
| Modifier and Type | Field | Description |
|---|---|---|
static java.lang.String |
CLASSPATH_URL_PREFIX |
|
static java.lang.String |
FILE_URL_PREFIX |
|
static java.lang.String |
JAR_FILE_SUFFIX |
|
static java.lang.String |
JAR_URL_PREFIX |
|
static java.lang.String |
JAR_URL_SEPARATOR |
|
static java.lang.String |
REGULAR_FILE_SEPARATOR |
|
static char |
REGULAR_FILE_SEPARATOR_CHAR |
|
static java.lang.String |
URL_PROTOCOL_CODE_SOURCE |
|
static java.lang.String |
URL_PROTOCOL_FILE |
|
static java.lang.String |
URL_PROTOCOL_JAR |
|
static java.lang.String |
URL_PROTOCOL_VFSZIP |
|
static java.lang.String |
URL_PROTOCOL_WSJAR |
|
static java.lang.String |
URL_PROTOCOL_ZIP |
|
static java.lang.String |
ZIP_FILE_SUFFIX |
| Constructor | Description |
|---|---|
ResourceUtils() |
| Modifier and Type | Method | Description |
|---|---|---|
static java.net.URL |
extractJarFileURL(java.net.URL jarUrl) |
|
static java.io.File |
getFile(java.lang.String resourceLocation,
java.lang.ClassLoader classLoader) |
|
static java.io.File |
getFile(java.net.URI resourceUri) |
|
static java.io.File |
getFile(java.net.URI resourceUri,
java.lang.String description) |
|
static java.io.File |
getFile(java.net.URL resourceUrl) |
|
static java.io.File |
getFile(java.net.URL resourceUrl,
java.lang.String description) |
|
static java.io.Reader |
getReader(java.io.File file,
java.lang.String encoding) |
Returns a Reader for reading the specified file.
|
static java.io.Reader |
getReader(java.net.URL url,
java.lang.String encoding) |
Returns a Reader for reading the specified url.
|
static java.net.URL |
getResource(java.lang.String resource) |
Returns the URL of the resource on the classpath.
|
static java.net.URL |
getResource(java.lang.String resource,
java.lang.ClassLoader classLoader) |
Returns the URL of the resource on the classpath.
|
static java.io.File |
getResourceAsFile(java.lang.String resource) |
|
static java.io.File |
getResourceAsFile(java.lang.String resource,
java.lang.ClassLoader classLoader) |
|
static java.io.InputStream |
getResourceAsStream(java.lang.String resource) |
Returns a resource on the classpath as a Stream object.
|
static java.io.InputStream |
getResourceAsStream(java.lang.String resource,
java.lang.ClassLoader classLoader) |
Returns a resource on the classpath as a Stream object.
|
static java.net.URL |
getURL(java.lang.String resourceLocation,
java.lang.ClassLoader classLoader) |
|
static boolean |
isJarSimilarURL(java.net.URL url) |
|
static boolean |
isJarURL(java.net.URL url) |
|
static boolean |
isUrl(java.lang.String resourceLocation) |
|
static java.lang.String |
read(java.io.File file,
java.lang.String encoding) |
Returns a string from the specified file.
|
static java.lang.String |
read(java.io.Reader reader) |
Returns a string from the specified Reader object.
|
static java.lang.String |
read(java.net.URL url,
java.lang.String encoding) |
Returns a string from the specified url.
|
static java.net.URI |
toURI(java.lang.String location) |
|
static java.net.URI |
toURI(java.net.URL url) |
public static final java.lang.String CLASSPATH_URL_PREFIX
public static final java.lang.String FILE_URL_PREFIX
public static final java.lang.String JAR_URL_PREFIX
public static final java.lang.String JAR_FILE_SUFFIX
public static final java.lang.String ZIP_FILE_SUFFIX
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 URL_PROTOCOL_VFSZIP
public static final java.lang.String URL_PROTOCOL_WSJAR
public static final java.lang.String URL_PROTOCOL_CODE_SOURCE
public static final java.lang.String JAR_URL_SEPARATOR
public static final java.lang.String REGULAR_FILE_SEPARATOR
public static final char REGULAR_FILE_SEPARATOR_CHAR
public static boolean isUrl(java.lang.String resourceLocation)
public static java.net.URL getURL(java.lang.String resourceLocation,
java.lang.ClassLoader classLoader)
throws java.io.FileNotFoundException
java.io.FileNotFoundExceptionpublic static java.io.File getFile(java.lang.String resourceLocation,
java.lang.ClassLoader classLoader)
throws java.io.FileNotFoundException
java.io.FileNotFoundExceptionpublic static java.io.File getFile(java.net.URL resourceUrl)
throws java.io.FileNotFoundException
java.io.FileNotFoundExceptionpublic static java.io.File getFile(java.net.URL resourceUrl,
java.lang.String description)
throws java.io.FileNotFoundException
java.io.FileNotFoundExceptionpublic static java.io.File getFile(java.net.URI resourceUri)
throws java.io.FileNotFoundException
java.io.FileNotFoundExceptionpublic static java.io.File getFile(java.net.URI resourceUri,
java.lang.String description)
throws java.io.FileNotFoundException
java.io.FileNotFoundExceptionpublic static boolean isJarURL(java.net.URL url)
public static boolean isJarSimilarURL(java.net.URL url)
public static java.net.URL extractJarFileURL(java.net.URL jarUrl)
throws java.net.MalformedURLException
java.net.MalformedURLExceptionpublic static java.net.URI toURI(java.net.URL url)
throws java.net.URISyntaxException
java.net.URISyntaxExceptionpublic static java.net.URI toURI(java.lang.String location)
throws java.net.URISyntaxException
java.net.URISyntaxExceptionpublic static java.net.URL getResource(java.lang.String resource)
throws java.io.IOException
resource - the resource to findURL object for reading the resource;
null if the resource could not be foundjava.io.IOException - if the resource cannot be found or readpublic static java.net.URL getResource(java.lang.String resource,
java.lang.ClassLoader classLoader)
throws java.io.IOException
classLoader - the class loader used to load the resourceresource - the resource to findURL object for reading the resource;
null if the resource could not be foundjava.io.IOException - if the resource cannot be found or readpublic static java.io.File getResourceAsFile(java.lang.String resource)
throws java.io.IOException
java.io.IOExceptionpublic static java.io.File getResourceAsFile(java.lang.String resource,
java.lang.ClassLoader classLoader)
throws java.io.IOException
java.io.IOExceptionpublic static java.io.InputStream getResourceAsStream(java.lang.String resource)
throws java.io.IOException
resource - the resource to findnull if the resource could not be foundjava.io.IOException - if the resource cannot be found or readpublic static java.io.InputStream getResourceAsStream(java.lang.String resource,
java.lang.ClassLoader classLoader)
throws java.io.IOException
resource - the resource to findclassLoader - the class loadernull if the resource could not be foundjava.io.IOException - if the resource cannot be found or readpublic static java.io.Reader getReader(java.io.File file,
java.lang.String encoding)
throws java.io.IOException
file - the fileencoding - the encodingjava.io.IOException - if an error occurred when reading resources using any I/O operationspublic static java.io.Reader getReader(java.net.URL url,
java.lang.String encoding)
throws java.io.IOException
url - the urlencoding - the encodingjava.io.IOException - if an error occurred when reading resources using any I/O operationspublic static java.lang.String read(java.io.File file,
java.lang.String encoding)
throws java.io.IOException
file - the fileencoding - the encodingjava.io.IOException - if an error occurred when reading resources using any I/O operationspublic static java.lang.String read(java.net.URL url,
java.lang.String encoding)
throws java.io.IOException
url - the urlencoding - the encodingjava.io.IOException - if an error occurred when reading resources using any I/O operationspublic static java.lang.String read(java.io.Reader reader)
throws java.io.IOException
reader - the readerjava.io.IOException - if an error occurred when reading resources using any I/O operationsCopyright © 2008–2018 The Aspectran Project. All rights reserved.