org.springframework.core.io

## 接口 WritableResource

- 所有超级接口:
    InputStreamSource, Resource
  所有已知实现类:
    FileSystemResource, FileUrlResource, PathResource

      public interface WritableResource
      extends Resource

  Extended interface for a resource that supports writing to it. Provides an `OutputStream accessor`.
  从以下版本开始:
    3.1
  作者:
    Juergen Hoeller
  另请参阅:
    `OutputStream`

- - ### 方法概要

    所有方法 实例方法 抽象方法 默认方法
    限定符和类型 | 方法和说明
    --- | ---
    `OutputStream` | `getOutputStream()` Return an `OutputStream` for the underlying resource, allowing to (over-)write its content.
    `default boolean` | `isWritable()` Indicate whether the contents of this resource can be written via `getOutputStream()`.
    `default WritableByteChannel` | `writableChannel()` Return a `WritableByteChannel`.

    - ### 从接口继承的方法 org.springframework.core.io.Resource

      `contentLength, createRelative, exists, getDescription, getFile, getFilename, getURI, getURL, isFile, isOpen, isReadable, lastModified, readableChannel`

    - ### 从接口继承的方法 org.springframework.core.io.InputStreamSource

      `getInputStream`

- - ### 方法详细资料

    - #### isWritable

          default boolean isWritable()

      Indicate whether the contents of this resource can be written via `getOutputStream()`.

      Will be `true` for typical resource descriptors; note that actual content writing may still fail when attempted. However, a value of `false` is a definitive indication that the resource content cannot be modified.

      另请参阅:
        `getOutputStream()`, `Resource.isReadable()`

    - #### getOutputStream

          OutputStream getOutputStream()
                                throws IOException

      Return an `OutputStream` for the underlying resource, allowing to (over-)write its content.
      抛出:
        `IOException` - if the stream could not be opened
      另请参阅:
        `InputStreamSource.getInputStream()`

    - #### writableChannel

          default WritableByteChannel writableChannel()
                                               throws IOException

      Return a `WritableByteChannel`.

      It is expected that each call creates a fresh channel.

      The default implementation returns `Channels.newChannel(OutputStream)` with the result of `getOutputStream()`.

      返回:
        the byte channel for the underlying resource (must not be `null`)
      抛出:
        `FileNotFoundException` - if the underlying resource doesn't exist
        `IOException` - if the content channel could not be opened
      从以下版本开始:
        5.0
      另请参阅:
        `getOutputStream()`