接口 InputStreamSource
- 所有已知子接口:
ContextResource
,EncodedResource
,MultipartFile
,Resource
,VersionedResource
,WritableResource
- 所有已知实现类:
AbstractFileResolvingResource
,AbstractResource
,ByteArrayResource
,ClassPathResource
,CommonsMultipartFile
,DefaultResourceLoader.ClassPathContextResource
,DescriptiveResource
,EncodedResource
,FileSystemResource
,InputStreamResource
,MockMultipartFile
,PathResource
,PortletContextResource
,ServletContextResource
,TransformedResource
,UrlResource
,VfsResource
public interface InputStreamSource
Simple interface for objects that are sources for anInputStream
.This is the base interface for Spring's more extensive
Resource
interface.For single-use streams,
InputStreamResource
can be used for any givenInputStream
. Spring'sByteArrayResource
or any file-basedResource
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.- 从以下版本开始:
- 20.01.2004
- 作者:
- Juergen Hoeller
- 另请参阅:
InputStream
,Resource
,InputStreamResource
,ByteArrayResource
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 InputStream
getInputStream()
Return anInputStream
for the content of an underlying resource.
方法详细资料
getInputStream
InputStream getInputStream() throws IOException
Return anInputStream
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 existIOException
- if the content stream could not be opened