org.springframework.core.io

## 类 VfsResource

- java.lang.Object
- - org.springframework.core.io.AbstractResource
  - - org.springframework.core.io.VfsResource

- 所有已实现的接口:
    InputStreamSource, Resource

      public class VfsResource
      extends AbstractResource

  JBoss VFS based `Resource` implementation.

  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
  另请参阅:
    `VirtualFile`

- - ### 构造器概要

    构造器
    构造器和说明
    `VfsResource(Object resource)` Create a new `VfsResource` wrapping the given resource handle.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `long` | `contentLength()` This implementation reads the entire InputStream to calculate the content length.
    `Resource` | `createRelative(String relativePath)` This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.
    `boolean` | `equals(Object other)` This implementation compares description strings.
    `boolean` | `exists()` This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened.
    `String` | `getDescription()` Return a description for this resource, to be used for error output when working with the resource.
    `File` | `getFile()` This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to an absolute file path.
    `String` | `getFilename()` This implementation always returns `null`, assuming that this resource type does not have a filename.
    `InputStream` | `getInputStream()` Return an `InputStream` for the content of an underlying resource.
    `URI` | `getURI()` This implementation builds a URI based on the URL returned by `AbstractResource.getURL()`.
    `URL` | `getURL()` This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to a URL.
    `int` | `hashCode()` This implementation returns the description's hash code.
    `boolean` | `isReadable()` This implementation always returns `true`.
    `long` | `lastModified()` This implementation checks the timestamp of the underlying File, if available.

    - ### 从类继承的方法 org.springframework.core.io.AbstractResource

      `getFileForLastModifiedCheck, isFile, isOpen, readableChannel, toString`

    - ### 从类继承的方法 java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### 构造器详细资料

    - #### VfsResource

          public VfsResource(Object resource)

      Create a new `VfsResource` wrapping the given resource handle.
      参数:
        `resource` - a `org.jboss.vfs.VirtualFile` instance (untyped in order to avoid a static dependency on the VFS API)

  - ### 方法详细资料

    - #### getInputStream

          public InputStream getInputStream()
                                     throws IOException

      从接口复制的说明: `InputStreamSource`
      Return an `InputStream` for 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 exist
        `IOException` - if the content stream could not be opened

    - #### 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 returns `true`.
      指定者:
        `isReadable` 在接口中 `Resource`
      覆盖:
        `isReadable` 在类中 `AbstractResource`
      另请参阅:
        `InputStreamSource.getInputStream()`

    - #### getURL

          public URL getURL()
                     throws IOException

      从类复制的说明: `AbstractResource`
      This 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

      从类复制的说明: `AbstractResource`
      This implementation builds a URI based on the URL returned by `AbstractResource.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

      从类复制的说明: `AbstractResource`
      This 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 system
        `IOException` - in case of general resolution/reading failures
      另请参阅:
        `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()`

    - #### createRelative

          public Resource createRelative(String relativePath)
                                  throws IOException

      从类复制的说明: `AbstractResource`
      This 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()

      从类复制的说明: `AbstractResource`
      This implementation always returns `null`, assuming that this resource type does not have a filename.
      指定者:
        `getFilename` 在接口中 `Resource`
      覆盖:
        `getFilename` 在类中 `AbstractResource`

    - #### getDescription

          public String getDescription()

      从接口复制的说明: `Resource`
      Return 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 `toString` method.

      另请参阅:
        `Object.toString()`

    - #### equals

          public boolean equals(Object other)

      从类复制的说明: `AbstractResource`
      This implementation compares description strings.
      覆盖:
        `equals` 在类中 `AbstractResource`
      另请参阅:
        `Resource.getDescription()`

    - #### hashCode

          public int hashCode()

      从类复制的说明: `AbstractResource`
      This implementation returns the description's hash code.
      覆盖:
        `hashCode` 在类中 `AbstractResource`
      另请参阅:
        `Resource.getDescription()`