接口 WritableResource
- 所有超级接口:
InputStreamSource,Resource
- 所有已知实现类:
FileSystemResource,FileUrlResource,PathResource
public interface WritableResource extends Resource
Extended interface for a resource that supports writing to it. Provides anOutputStream accessor.- 从以下版本开始:
- 3.1
- 作者:
- Juergen Hoeller
- 另请参阅:
OutputStream
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 OutputStreamgetOutputStream()Return anOutputStreamfor the underlying resource, allowing to (over-)write its content.default booleanisWritable()Indicate whether the contents of this resource can be written viagetOutputStream().default WritableByteChannelwritableChannel()Return aWritableByteChannel.从接口继承的方法 org.springframework.core.io.InputStreamSource
getInputStream
从接口继承的方法 org.springframework.core.io.Resource
contentLength, createRelative, exists, getDescription, getFile, getFilename, getURI, getURL, isFile, isOpen, isReadable, lastModified, readableChannel
方法详细资料
isWritable
default boolean isWritable()
Indicate whether the contents of this resource can be written viagetOutputStream().Will be
truefor typical resource descriptors; note that actual content writing may still fail when attempted. However, a value offalseis a definitive indication that the resource content cannot be modified.
getOutputStream
OutputStream getOutputStream() throws IOException
Return anOutputStreamfor 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 aWritableByteChannel.It is expected that each call creates a fresh channel.
The default implementation returns
Channels.newChannel(OutputStream)with the result ofgetOutputStream().- 返回:
- the byte channel for the underlying resource (must not be
null) - 抛出:
FileNotFoundException- if the underlying resource doesn't existIOException- if the content channel could not be opened- 从以下版本开始:
- 5.0
- 另请参阅:
getOutputStream()