public abstract class AbstractFileResolvingResource extends AbstractResource
UrlResource or ClassPathResource.
Detects the "file" protocol as well as the JBoss "vfs" protocol in URLs, resolving file system references accordingly.
| Constructor and Description |
|---|
AbstractFileResolvingResource() |
| Modifier and Type | Method and Description |
|---|---|
long |
contentLength()
This implementation reads the entire InputStream to calculate the
content length.
|
protected void |
customizeConnection(java.net.HttpURLConnection con)
Customize the given
HttpURLConnection, obtained in the course of an
exists(), contentLength() or lastModified() call. |
protected void |
customizeConnection(java.net.URLConnection con)
Customize the given
URLConnection, obtained in the course of an
exists(), contentLength() or lastModified() call. |
boolean |
exists()
This implementation checks whether a File can be opened,
falling back to whether an InputStream can be opened.
|
java.io.File |
getFile()
This implementation returns a File reference for the underlying class path
resource, provided that it refers to a file in the file system.
|
protected java.io.File |
getFile(java.net.URI uri)
This implementation returns a File reference for the given URI-identified
resource, provided that it refers to a file in the file system.
|
protected java.io.File |
getFileForLastModifiedCheck()
This implementation determines the underlying File
(or jar file, in case of a resource in a jar/zip).
|
boolean |
isFile()
This implementation always returns
false. |
protected boolean |
isFile(java.net.URI uri)
This implementation returns a File reference for the given URI-identified
resource, provided that it refers to a file in the file system.
|
boolean |
isReadable()
This implementation always returns
true. |
long |
lastModified()
This implementation checks the timestamp of the underlying File,
if available.
|
java.nio.channels.ReadableByteChannel |
readableChannel()
This implementation returns a FileChannel for the given URI-identified
resource, provided that it refers to a file in the file system.
|
createRelative, equals, getFilename, getURI, getURL, hashCode, isOpen, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetDescriptiongetInputStreampublic boolean exists()
AbstractResourceexists in interface Resourceexists in class AbstractResourcepublic boolean isReadable()
AbstractResourcetrue.isReadable in interface ResourceisReadable in class AbstractResourceInputStreamSource.getInputStream()public boolean isFile()
AbstractResourcefalse.isFile in interface ResourceisFile in class AbstractResourceResource.getFile()public java.io.File getFile()
throws java.io.IOException
getFile in interface ResourcegetFile in class AbstractResourcejava.io.FileNotFoundException - if the resource cannot be resolved as
absolute file path, i.e. if the resource is not available in a file systemjava.io.IOException - in case of general resolution/reading failuresResourceUtils.getFile(java.net.URL, String)protected java.io.File getFileForLastModifiedCheck()
throws java.io.IOException
getFileForLastModifiedCheck in class AbstractResourcenull)java.io.FileNotFoundException - if the resource cannot be resolved as
an absolute file path, i.e. is not available in a file systemjava.io.IOException - in case of general resolution/reading failuresprotected boolean isFile(java.net.URI uri)
getFile(URI)protected java.io.File getFile(java.net.URI uri)
throws java.io.IOException
java.io.IOExceptionResourceUtils.getFile(java.net.URI, String)public java.nio.channels.ReadableByteChannel readableChannel()
throws java.io.IOException
readableChannel in interface ResourcereadableChannel in class AbstractResourcenull)java.io.FileNotFoundException - if the underlying resource doesn't existjava.io.IOException - if the content channel could not be openedgetFile()public long contentLength()
throws java.io.IOException
AbstractResourcecontentLength in interface ResourcecontentLength in class AbstractResourcejava.io.IOException - if the resource cannot be resolved
(in the file system or as some other known physical resource type)InputStreamSource.getInputStream()public long lastModified()
throws java.io.IOException
AbstractResourcelastModified in interface ResourcelastModified in class AbstractResourcejava.io.IOException - if the resource cannot be resolved
(in the file system or as some other known physical resource type)AbstractResource.getFileForLastModifiedCheck()protected void customizeConnection(java.net.URLConnection con)
throws java.io.IOException
URLConnection, obtained in the course of an
exists(), contentLength() or lastModified() call.
Calls ResourceUtils.useCachesIfNecessary(URLConnection) and
delegates to customizeConnection(HttpURLConnection) if possible.
Can be overridden in subclasses.
con - the URLConnection to customizejava.io.IOException - if thrown from URLConnection methodsprotected void customizeConnection(java.net.HttpURLConnection con)
throws java.io.IOException
HttpURLConnection, obtained in the course of an
exists(), contentLength() or lastModified() call.
Sets request method "HEAD" by default. Can be overridden in subclasses.
con - the HttpURLConnection to customizejava.io.IOException - if thrown from HttpURLConnection methods