|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.util.ResourceUtils
Utility methods for resolving resource locations to files in the file system. Mainly for internal use within the framework.
Consider using Spring's Resource abstraction in the core package
for handling all kinds of file resources in a uniform manner.
ResourceLoader's getLocation
can resolve any location to a
Resource object, which in turn allows to get a java.io.File
in the file system through its getFile
method.
The main reason for these utility methods for resource location handling is to support Log4jConfigurer, which must be able to resolve resource locations before the logging system has been initialized. Spring' Resource abstraction in the core package, on the other hand, already expects the logging system to be available.
Resource
,
ClassPathResource
,
FileSystemResource
,
UrlResource
,
ResourceLoader
Field Summary | |
static String |
CLASSPATH_URL_PREFIX
Pseudo URL prefix for loading from the class path: "classpath:" |
static String |
URL_PROTOCOL_FILE
URL protocol for a file in the file system: "file" |
Constructor Summary | |
ResourceUtils()
|
Method Summary | |
static File |
getFile(String resourceLocation)
Resolve the given resource location to a java.io.File ,
i.e. to a file in the file system.
|
static File |
getFile(URL resourceUrl)
Resolve the given resource URL to a java.io.File ,
i.e. to a file in the file system. |
static File |
getFile(URL resourceUrl,
String description)
Resolve the given resource URL to a java.io.File ,
i.e. to a file in the file system. |
static URL |
getURL(String resourceLocation)
Resolve the given resource location to a java.io.File ,
i.e. to a file in the file system.
|
static boolean |
isUrl(String resourceLocation)
Return whether the given resource location is a URL: either a special "classpath" pseudo URL or a standard URL. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String CLASSPATH_URL_PREFIX
public static final String URL_PROTOCOL_FILE
Constructor Detail |
public ResourceUtils()
Method Detail |
public static boolean isUrl(String resourceLocation)
CLASSPATH_URL_PREFIX
,
URL
public static URL getURL(String resourceLocation) throws 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 path
FileNotFoundException
- if the resource cannot be resolved to
a file in the file systempublic static File getFile(String resourceLocation) throws FileNotFoundException
java.io.File
,
i.e. to a file in the file system.
Does not check whether the fil 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 path
FileNotFoundException
- if the resource cannot be resolved to
a file in the file systempublic static File getFile(URL resourceUrl) throws FileNotFoundException
java.io.File
,
i.e. to a file in the file system.
resourceUrl
- the resource URL to resolve
FileNotFoundException
- if the URL cannot be resolved to
a file in the file systempublic static File getFile(URL resourceUrl, String description) throws FileNotFoundException
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)
FileNotFoundException
- if the URL cannot be resolved to
a file in the file system
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |