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.
| 构造器和说明 |
|---|
AbstractFileResolvingResource() |
| 限定符和类型 | 方法和说明 |
|---|---|
long |
contentLength()
This implementation reads the entire InputStream to calculate the
content length.
|
protected void |
customizeConnection(HttpURLConnection con)
Customize the given
HttpURLConnection, obtained in the course of an
exists(), contentLength() or lastModified() call. |
protected void |
customizeConnection(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.
|
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 File |
getFile(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 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(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 for a resource
that exists (revised as of 5.1). |
long |
lastModified()
This implementation checks the timestamp of the underlying File,
if available.
|
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, toStringgetDescriptiongetInputStreampublic boolean exists()
AbstractResourceexists 在接口中 Resourceexists 在类中 AbstractResourcepublic boolean isReadable()
AbstractResourcetrue for a resource
that exists (revised as of 5.1).isReadable 在接口中 ResourceisReadable 在类中 AbstractResourceInputStreamSource.getInputStream(),
Resource.exists()public boolean isFile()
AbstractResourcefalse.isFile 在接口中 ResourceisFile 在类中 AbstractResourceResource.getFile()public File getFile() throws IOException
getFile 在接口中 ResourcegetFile 在类中 AbstractResourceFileNotFoundException - if the resource cannot be resolved as
absolute file path, i.e. if the resource is not available in a file systemIOException - in case of general resolution/reading failuresorg.springframework.util.ResourceUtils#getFile(URL, String)protected File getFileForLastModifiedCheck() throws IOException
getFileForLastModifiedCheck 在类中 AbstractResourcenull)FileNotFoundException - if the resource cannot be resolved as
an absolute file path, i.e. is not available in a file systemIOException - in case of general resolution/reading failuresprotected boolean isFile(URI uri)
getFile(URI)protected File getFile(URI uri) throws IOException
IOExceptionorg.springframework.util.ResourceUtils#getFile(URI, String)public ReadableByteChannel readableChannel() throws IOException
readableChannel 在接口中 ResourcereadableChannel 在类中 AbstractResourcenull)FileNotFoundException - if the underlying resource doesn't existIOException - if the content channel could not be openedgetFile()public long contentLength()
throws IOException
AbstractResourcecontentLength 在接口中 ResourcecontentLength 在类中 AbstractResourceIOException - if the resource cannot be resolved
(in the file system or as some other known physical resource type)InputStreamSource.getInputStream()public long lastModified()
throws IOException
AbstractResourcelastModified 在接口中 ResourcelastModified 在类中 AbstractResourceIOException - if the resource cannot be resolved
(in the file system or as some other known physical resource type)AbstractResource.getFileForLastModifiedCheck()protected void customizeConnection(URLConnection con) throws 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 customizeIOException - if thrown from URLConnection methodsprotected void customizeConnection(HttpURLConnection con) throws 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 customizeIOException - if thrown from HttpURLConnection methodsCopyright © 2020. All rights reserved.