Constructor and Description |
---|
FileSystemResource(File file)
Create a new FileSystemResource from a File handle.
|
FileSystemResource(String path)
Create a new FileSystemResource from a file path.
|
Modifier and Type | Method and Description |
---|---|
protected void |
assertNotNull(Object object,
String message)
Assert that an object is not null.
|
long |
contentLength()
This implementation returns the underlying File's length.
|
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.
|
OutputStream |
getOutputStream()
This implementation opens a FileOutputStream for the underlying file.
|
String |
getPath() |
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).
|
boolean |
isWritable()
This implementation checks whether the underlying file is marked as writable
(and corresponds to an actual file with content, not to a directory).
|
long |
lastModified()
Determine the last-modified timestamp for this resource.
|
String |
toString() |
public FileSystemResource(File file)
file
- a File handlepublic FileSystemResource(String path)
path
- a file pathpublic final String getPath()
public boolean exists()
exists
in interface Resource
File.exists()
public boolean isReadable()
isReadable
in interface Resource
File.canRead()
,
File.isDirectory()
public InputStream getInputStream() throws IOException
getInputStream
in interface Resource
IOException
- if there is an errorFileInputStream
public URL getURL() throws IOException
getURL
in interface Resource
IOException
- if the resource cannot be resolved as URL,
i.e. if the resource is not available as descriptorFile.toURI()
public URI getURI() throws IOException
getURI
in interface Resource
IOException
- if the resource cannot be resolved as URI,
i.e. if the resource is not available as descriptorFile.toURI()
public File getFile()
public long contentLength() throws IOException
contentLength
in interface Resource
IOException
- if the resource cannot be resolved
(in the file system or as some other known physical resource type)public long lastModified() throws IOException
Resource
lastModified
in interface Resource
IOException
- if the resource cannot be resolved
(in the file system or as some other known physical resource type)public String getFilename()
getFilename
in interface Resource
File.getName()
public String getDescription()
getDescription
in interface Resource
File.getAbsolutePath()
public Resource createRelative(String relativePath)
createRelative
in interface Resource
relativePath
- The relative pathpublic boolean isWritable()
File.canWrite()
,
File.isDirectory()
public OutputStream getOutputStream() throws IOException
IOException
- if there is an errorFileOutputStream
public boolean equals(Object obj)
public int hashCode()
protected void assertNotNull(Object object, String message)
object
- The object to checkmessage
- The error message thrown if the object is null