接口 InputStreamSource
- 所有超级接口:
Consumer<OutputStream>,ThrowingConsumer<OutputStream>
- 所有已知子接口:
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
- 另请参阅:
-
方法概要
修饰符和类型方法说明default voidPerforms this operation on the given argument, possibly throwing a checked exception.Return anInputStreamfor the content of an underlying resource.default ReaderGetReaderdefault ReaderGetReaderdefault ReadableByteChannelReturn aReadableByteChannel.default longtransferTo(OutputStream out) Reads all bytes from thisgetInputStream()and writes the bytes to the given output stream in the order that they are read.从接口继承的方法 cn.taketoday.util.function.ThrowingConsumer
accept, accept, throwing
-
方法详细资料
-
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- 另请参阅:
-
transferTo
Reads all bytes from thisgetInputStream()and writes the bytes to the given output stream in the order that they are read. On return, this input stream will be at end of stream. This method does not close either stream.This method may block indefinitely reading from the input stream, or writing to the output stream. The behavior for the case where the input and/or output stream is asynchronously closed, or the thread interrupted during the transfer, is highly input and output stream specific, and therefore not specified.
If an I/O error occurs reading from the input stream or writing to the output stream, then it may do so after some bytes have been read or written. Consequently the input stream may not be at end of stream and one, or both, streams may be in an inconsistent state. It is strongly recommended that both streams be promptly closed if an I/O error occurs.
- 参数:
out- the output stream, non-null- 返回:
- the number of bytes transferred
- 抛出:
IOException- if an I/O error occurs when reading or writingNullPointerException- ifoutisnull- 从以下版本开始:
- 4.0
-
acceptWithException
从接口复制的说明:ThrowingConsumerPerforms this operation on the given argument, possibly throwing a checked exception.- 指定者:
acceptWithException在接口中ThrowingConsumer<OutputStream>- 参数:
out- the output stream, non-null- 抛出:
Exception- on error- 另请参阅:
-