类 AbstractFileResolvingResource
- java.lang.Object
- org.springframework.core.io.AbstractResource
- org.springframework.core.io.AbstractFileResolvingResource
- 所有已实现的接口:
InputStreamSource
,Resource
public abstract class AbstractFileResolvingResource extends AbstractResource
Abstract base class for resources which resolve URLs into File references, such asUrlResource
orClassPathResource
.Detects the "file" protocol as well as the JBoss "vfs" protocol in URLs, resolving file system references accordingly.
- 从以下版本开始:
- 3.0
- 作者:
- Juergen Hoeller
构造器概要
构造器 构造器 说明 AbstractFileResolvingResource()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 long
contentLength()
This implementation reads the entire InputStream to calculate the content length.protected void
customizeConnection(HttpURLConnection con)
Customize the givenHttpURLConnection
, obtained in the course of anexists()
,contentLength()
orlastModified()
call.protected void
customizeConnection(URLConnection con)
Customize the givenURLConnection
, obtained in the course of anexists()
,contentLength()
orlastModified()
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
isReadable()
This implementation always returnstrue
.long
lastModified()
This implementation checks the timestamp of the underlying File, if available.从类继承的方法 org.springframework.core.io.AbstractResource
createRelative, equals, getFilename, getURI, getURL, hashCode, isOpen, toString
从接口继承的方法 org.springframework.core.io.InputStreamSource
getInputStream
从接口继承的方法 org.springframework.core.io.Resource
getDescription
构造器详细资料
AbstractFileResolvingResource
public AbstractFileResolvingResource()
方法详细资料
getFile
public File getFile() throws IOException
This implementation returns a File reference for the underlying class path resource, provided that it refers to a file in the file system.- 指定者:
getFile
在接口中Resource
- 覆盖:
getFile
在类中AbstractResource
- 抛出:
FileNotFoundException
- 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 failures- 另请参阅:
ResourceUtils.getFile(java.net.URL, String)
getFileForLastModifiedCheck
protected File getFileForLastModifiedCheck() throws IOException
This implementation determines the underlying File (or jar file, in case of a resource in a jar/zip).- 覆盖:
getFileForLastModifiedCheck
在类中AbstractResource
- 返回:
- the File to use for timestamp checking (never
null
) - 抛出:
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 failures
getFile
protected File getFile(URI uri) throws IOException
This implementation returns a File reference for the given URI-identified resource, provided that it refers to a file in the file system.
exists
public boolean exists()
从类复制的说明:AbstractResource
This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened. This will cover both directories and content resources.- 指定者:
exists
在接口中Resource
- 覆盖:
exists
在类中AbstractResource
isReadable
public boolean isReadable()
从类复制的说明:AbstractResource
This implementation always returnstrue
.- 指定者:
isReadable
在接口中Resource
- 覆盖:
isReadable
在类中AbstractResource
- 另请参阅:
InputStreamSource.getInputStream()
contentLength
public long contentLength() throws IOException
从类复制的说明:AbstractResource
This implementation reads the entire InputStream to calculate the content length. Subclasses will almost always be able to provide a more optimal version of this, e.g. checking a File length.- 指定者:
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()
lastModified
public long lastModified() throws IOException
从类复制的说明:AbstractResource
This implementation checks the timestamp of the underlying File, if available.- 指定者:
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()
customizeConnection
protected void customizeConnection(URLConnection con) throws IOException
Customize the givenURLConnection
, obtained in the course of anexists()
,contentLength()
orlastModified()
call.Calls
ResourceUtils.useCachesIfNecessary(URLConnection)
and delegates tocustomizeConnection(HttpURLConnection)
if possible. Can be overridden in subclasses.- 参数:
con
- the URLConnection to customize- 抛出:
IOException
- if thrown from URLConnection methods
customizeConnection
protected void customizeConnection(HttpURLConnection con) throws IOException
Customize the givenHttpURLConnection
, obtained in the course of anexists()
,contentLength()
orlastModified()
call.Sets request method "HEAD" by default. Can be overridden in subclasses.
- 参数:
con
- the HttpURLConnection to customize- 抛出:
IOException
- if thrown from HttpURLConnection methods