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 underlying class path
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 |
isReadable()
This implementation always returns
true . |
long |
lastModified()
This implementation checks the timestamp of the underlying File,
if available.
|
createRelative, equals, getFilename, getURI, getURL, hashCode, isOpen, toString
getDescription
getInputStream
public File getFile() throws IOException
getFile
在接口中 Resource
getFile
在类中 AbstractResource
IOException
- if the resource cannot be resolved as absolute
file path, i.e. if the resource is not available in a file systemorg.springframework.util.UrlUtils#getFile(java.net.URL, String)
protected File getFileForLastModifiedCheck() throws IOException
getFileForLastModifiedCheck
在类中 AbstractResource
null
)IOException
- if the resource cannot be resolved as absolute
file path, i.e. if the resource is not available in a file systemprotected File getFile(URI uri) throws IOException
IOException
org.springframework.util.UrlUtils#getFile(java.net.URI, String)
public boolean exists()
AbstractResource
exists
在接口中 Resource
exists
在类中 AbstractResource
public boolean isReadable()
AbstractResource
true
.isReadable
在接口中 Resource
isReadable
在类中 AbstractResource
InputStreamSource.getInputStream()
public long contentLength() throws IOException
AbstractResource
contentLength
在接口中 Resource
contentLength
在类中 AbstractResource
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 IOException
AbstractResource
lastModified
在接口中 Resource
lastModified
在类中 AbstractResource
IOException
- 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 UrlUtils.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 © 2018 jretty-org. All rights reserved.