类 VfsResource
- java.lang.Object
- org.springframework.core.io.AbstractResource
- org.springframework.core.io.VfsResource
- 所有已实现的接口:
InputStreamSource,Resource
public class VfsResource extends AbstractResource
JBoss VFS basedResourceimplementation.As of Spring 4.0, this class supports VFS 3.x on JBoss AS 6+ (package
org.jboss.vfs) and is in particular compatible with JBoss AS 7 and WildFly 8+.- 从以下版本开始:
- 3.0
- 作者:
- Ales Justin, Juergen Hoeller, Costin Leau, Sam Brannen
- 另请参阅:
org.jboss.vfs.VirtualFile
构造器概要
构造器 构造器 说明 VfsResource(Object resource)Create a newVfsResourcewrapping the given resource handle.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 longcontentLength()This implementation reads the entire InputStream to calculate the content length.ResourcecreateRelative(String relativePath)This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.booleanequals(Object obj)This implementation compares description strings.booleanexists()This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened.StringgetDescription()Return a description for this resource, to be used for error output when working with the resource.FilegetFile()This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to an absolute file path.StringgetFilename()This implementation always returnsnull, assuming that this resource type does not have a filename.InputStreamgetInputStream()Return anInputStreamfor the content of an underlying resource.URIgetURI()This implementation builds a URI based on the URL returned byAbstractResource.getURL().URLgetURL()This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to a URL.inthashCode()This implementation returns the description's hash code.booleanisReadable()This implementation always returnstrue.longlastModified()This implementation checks the timestamp of the underlying File, if available.从类继承的方法 org.springframework.core.io.AbstractResource
getFileForLastModifiedCheck, isOpen, toString
构造器详细资料
VfsResource
public VfsResource(Object resource)
Create a newVfsResourcewrapping the given resource handle.- 参数:
resource- aorg.jboss.vfs.VirtualFileinstance (untyped in order to avoid a static dependency on the VFS API)
方法详细资料
getInputStream
public InputStream getInputStream() throws IOException
从接口复制的说明:InputStreamSourceReturn anInputStreamfor the content of an underlying resource.It is expected that each call creates a fresh stream.
This requirement is particularly important when you consider an API such as JavaMail, which needs to be able to read the stream multiple times when creating mail attachments. For such a use case, it is required that each
getInputStream()call returns a fresh stream.- 返回:
- the input stream for the underlying resource (must not be
null) - 抛出:
FileNotFoundException- if the underlying resource doesn't existIOException- if the content stream could not be opened
exists
public boolean exists()
从类复制的说明:AbstractResourceThis 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()
从类复制的说明:AbstractResourceThis implementation always returnstrue.- 指定者:
isReadable在接口中Resource- 覆盖:
isReadable在类中AbstractResource- 另请参阅:
InputStreamSource.getInputStream()
getURL
public URL getURL() throws IOException
从类复制的说明:AbstractResourceThis implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to a URL.- 指定者:
getURL在接口中Resource- 覆盖:
getURL在类中AbstractResource- 抛出:
IOException- if the resource cannot be resolved as URL, i.e. if the resource is not available as descriptor
getURI
public URI getURI() throws IOException
从类复制的说明:AbstractResourceThis implementation builds a URI based on the URL returned byAbstractResource.getURL().- 指定者:
getURI在接口中Resource- 覆盖:
getURI在类中AbstractResource- 抛出:
IOException- if the resource cannot be resolved as URI, i.e. if the resource is not available as descriptor
getFile
public File getFile() throws IOException
从类复制的说明:AbstractResourceThis implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to an absolute file path.- 指定者:
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- 另请参阅:
InputStreamSource.getInputStream()
contentLength
public long contentLength() throws IOException
从类复制的说明:AbstractResourceThis 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
从类复制的说明:AbstractResourceThis 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()
createRelative
public Resource createRelative(String relativePath) throws IOException
从类复制的说明:AbstractResourceThis implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.- 指定者:
createRelative在接口中Resource- 覆盖:
createRelative在类中AbstractResource- 参数:
relativePath- the relative path (relative to this resource)- 返回:
- the resource handle for the relative resource
- 抛出:
IOException- if the relative resource cannot be determined
getFilename
public String getFilename()
从类复制的说明:AbstractResourceThis implementation always returnsnull, assuming that this resource type does not have a filename.- 指定者:
getFilename在接口中Resource- 覆盖:
getFilename在类中AbstractResource
getDescription
public String getDescription()
从接口复制的说明:ResourceReturn a description for this resource, to be used for error output when working with the resource.Implementations are also encouraged to return this value from their
toStringmethod.- 另请参阅:
Object.toString()
equals
public boolean equals(Object obj)
从类复制的说明:AbstractResourceThis implementation compares description strings.- 覆盖:
equals在类中AbstractResource- 另请参阅:
Resource.getDescription()
hashCode
public int hashCode()
从类复制的说明:AbstractResourceThis implementation returns the description's hash code.- 覆盖:
hashCode在类中AbstractResource- 另请参阅:
Resource.getDescription()