|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Resource
Represents a resource on the server that may be used for server side processing, or may be exposed to the client side. Generally, this represents an abstraction on top of files on the class path and files stored in the web application context.
Resources are often used as map keys; they should be immutable and should implement hashCode() and equals().
Method Summary | |
---|---|
boolean |
exists()
Returns true if the resource exists; if a stream to the content of the file may be opened. |
Resource |
forFile(String relativePath)
Returns a Resource based on a relative path, relative to the folder containing the resource. |
Resource |
forLocale(Locale locale)
Returns a localized version of the resource. |
String |
getFile()
Returns the file portion of the Resource path, everything that follows the final forward slash. |
String |
getFolder()
Returns the portion of the path up to the last forward slash; this is the directory or folder portion of the Resource. |
String |
getPath()
Return the path (the combination of folder and file). |
InputStream |
openStream()
Opens a stream to the content of the resource, or returns null if the resource does not exist. |
URL |
toURL()
Returns the URL for the resource, or null if it does not exist. |
Resource |
withExtension(String extension)
Returns a new Resource with the extension changed (or, if the resource does not have an extension, the extension is added). |
Method Detail |
---|
boolean exists()
toURL()
returns a non-null value. Starting in release 5.3.4, the result of this is cached.
InputStream openStream() throws IOException
IOException
URL toURL()
Resource forLocale(Locale locale)
Resource forFile(String relativePath)
Resource withExtension(String extension)
toURL()
may return null.
extension
- to apply to the resource, such as "html" or "properties"
String getFolder()
String getFile()
String getPath()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |