接口 InputStreamSource
- 所有已知子接口:
ContextResource,Resource,WritableResource
- 所有已知实现类:
AbstractFileResolvingResource,AbstractResource,AppendableConsumerInputStreamSource,ByteArrayResource,ClassPathResource,ClassRelativeResourceLoader.ClassRelativeContextResource,DefaultResourceLoader.ClassPathContextResource,DescriptiveResource,EncodedResource,FileSystemResource,FileSystemResourceLoader.FileSystemContextResource,FileUrlResource,InputStreamResource,ModuleResource,PathResource,ResourceDecorator,UrlResource,WritableResourceDecorator
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
InputStream.
This is the base interface for Infra more extensive Resource interface.
For single-use streams, InputStreamResource can be used for any
given InputStream. Infra ByteArrayResource or any
file-based Resource implementation can be used as a concrete
instance, allowing one to read the underlying content stream multiple times.
This makes this interface useful as an abstract content source for mail
attachments, for example.
- 从以下版本开始:
- 2.1.6 2019-07-08 00:12
- 作者:
- Juergen Hoeller, Harry Yang
- 另请参阅:
-
方法概要
修饰符和类型方法说明Return anInputStreamfor the content of an underlying resource.default ReaderGetReaderdefault ReaderGetReaderdefault ReadableByteChannelReturn aReadableByteChannel.
-
方法详细资料
-
getInputStream
Return 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 does not existIOException- if the content stream could not be opened- 另请参阅:
-
getReader
GetReader- 抛出:
IOException- If an input exception occurs
-
getReader
GetReader- 参数:
encoding- Charset string- 抛出:
IOException- If an input exception occurs
-
readableChannel
Return aReadableByteChannel.It is expected that each call creates a fresh channel.
The default implementation returns
Channels.newChannel(InputStream)with the result ofgetInputStream().- 返回:
- 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- 另请参阅:
-