Class Overview
Resource
implementation for java.io.File
handles.
Obviously supports resolution as File, and also as URL.
Summary
Public Methods |
Resource
|
createRelative(String relativePath)
This implementation creates a FileSystemResource, applying the given path
relative to the path of the underlying file of this resource descriptor.
|
boolean
|
equals(Object obj)
This implementation compares the underlying File references.
|
boolean
|
exists()
This implementation returns whether the underlying file exists.
|
String
|
getDescription()
This implementation returns a description that includes the absolute
path of the file.
|
File
|
getFile()
This implementation returns the underlying File reference.
|
String
|
getFilename()
This implementation returns the name of the file.
|
InputStream
|
getInputStream()
This implementation opens a FileInputStream for the underlying file.
|
final
String
|
getPath()
Return the file path for this resource.
|
URI
|
getURI()
This implementation returns a URI for the underlying file.
|
URL
|
getURL()
This implementation returns a URL for the underlying file.
|
int
|
hashCode()
This implementation returns the hash code of the underlying File reference.
|
boolean
|
isReadable()
This implementation checks whether the underlying file is marked as readable
(and corresponds to an actual file with content, not to a directory).
|
[Expand]
Inherited Methods |
From class
org.springframework.core.io.AbstractResource
long
|
contentLength()
This implementation checks the timestamp of the underlying File,
if available.
|
Resource
|
createRelative(String relativePath)
This implementation throws a FileNotFoundException, assuming
that relative resources cannot be created for this resource.
|
boolean
|
equals(Object obj)
This implementation compares description strings.
|
boolean
|
exists()
This implementation checks whether a File can be opened,
falling back to whether an InputStream can be opened.
|
File
|
getFile()
This implementation throws a FileNotFoundException, assuming
that the resource cannot be resolved to an absolute file path.
|
File
|
getFileForLastModifiedCheck()
Determine the File to use for timestamp checking.
|
String
|
getFilename()
This implementation always throws IllegalStateException,
assuming that the resource does not have a filename.
|
URI
|
getURI()
This implementation builds a URI based on the URL returned
by getURL() .
|
URL
|
getURL()
This implementation throws a FileNotFoundException, assuming
that the resource cannot be resolved to a URL.
|
int
|
hashCode()
This implementation returns the description's hash code.
|
boolean
|
isOpen()
This implementation always returns false .
|
boolean
|
isReadable()
This implementation always returns true .
|
long
|
lastModified()
This implementation checks the timestamp of the underlying File,
if available.
|
String
|
toString()
This implementation returns the description of this resource.
|
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
From interface
org.springframework.core.io.InputStreamSource
|
From interface
org.springframework.core.io.Resource
abstract
long
|
contentLength()
Determine the content length for this resource.
|
abstract
Resource
|
createRelative(String relativePath)
Create a resource relative to this resource.
|
abstract
boolean
|
exists()
Return whether this resource actually exists in physical form.
|
abstract
String
|
getDescription()
Return a description for this resource,
to be used for error output when working with the resource.
|
abstract
File
|
getFile()
Return a File handle for this resource.
|
abstract
String
|
getFilename()
Return a filename for this resource, i.e.
|
abstract
URI
|
getURI()
Return a URI handle for this resource.
|
abstract
URL
|
getURL()
Return a URL handle for this resource.
|
abstract
boolean
|
isOpen()
Return whether this resource represents a handle with an open
stream.
|
abstract
boolean
|
isReadable()
Return whether the contents of this resource can be read,
e.g.
|
abstract
long
|
lastModified()
Determine the last-modified timestamp for this resource.
|
|
Public Constructors
public
FileSystemResource
(File file)
Create a new FileSystemResource from a File handle.
Note: When building relative resources via createRelative(String)
,
the relative path will apply at the same directory level:
e.g. new File("C:/dir1"), relative path "dir2" -> "C:/dir2"!
If you prefer to have relative paths built underneath the given root
directory, use the constructor with a file path
to append a trailing slash to the root path: "C:/dir1/", which
indicates this directory as root for all relative paths.
public
FileSystemResource
(String path)
Create a new FileSystemResource from a file path.
Note: When building relative resources via createRelative(String)
,
it makes a difference whether the specified resource base path here
ends with a slash or not. In the case of "C:/dir1/", relative paths
will be built underneath that root: e.g. relative path "dir2" ->
"C:/dir1/dir2". In the case of "C:/dir1", relative paths will apply
at the same directory level: relative path "dir2" -> "C:/dir2".
Public Methods
public
Resource
createRelative
(String relativePath)
This implementation creates a FileSystemResource, applying the given path
relative to the path of the underlying file of this resource descriptor.
Parameters
relativePath
| the relative path (relative to this resource) |
Returns
- the resource handle for the relative resource
public
boolean
equals
(Object obj)
This implementation compares the underlying File references.
public
boolean
exists
()
This implementation returns whether the underlying file exists.
public
String
getDescription
()
This implementation returns a description that includes the absolute
path of the file.
public
File
getFile
()
This implementation returns the underlying File reference.
public
String
getFilename
()
This implementation returns the name of the file.
public
InputStream
getInputStream
()
This implementation opens a FileInputStream for the underlying file.
public
final
String
getPath
()
Return the file path for this resource.
public
URI
getURI
()
This implementation returns a URI for the underlying file.
public
URL
getURL
()
This implementation returns a URL for the underlying file.
public
int
hashCode
()
This implementation returns the hash code of the underlying File reference.
public
boolean
isReadable
()
This implementation checks whether the underlying file is marked as readable
(and corresponds to an actual file with content, not to a directory).