Interface InputStreamSource
- All Known Subinterfaces:
ContextResource
,HttpResource
,HttpResource
,MultipartFile
,Resource
,WritableResource
- All Known Implementing Classes:
AbstractFileResolvingResource
,AbstractResource
,ByteArrayResource
,ClassPathResource
,DefaultResourceLoader.ClassPathContextResource
,DescriptiveResource
,EncodedResource
,FileSystemResource
,FileUrlResource
,InputStreamResource
,MockMultipartFile
,ModuleResource
,PathResource
,ServletContextResource
,TransformedResource
,TransformedResource
,UrlResource
,VfsResource
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
InputStream
.
This is the base interface for Spring's more extensive Resource
interface.
For single-use streams, InputStreamResource
can be used for any
given InputStream
. Spring's 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.
- Since:
- 20.01.2004
- Author:
- Juergen Hoeller
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturn anInputStream
for the content of an underlying resource.
-
Method Details
-
getInputStream
Return anInputStream
for the content of an underlying resource.It is usually expected that every such 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.- Returns:
- the input stream for the underlying resource (must not be
null
) - Throws:
FileNotFoundException
- if the underlying resource does not existIOException
- if the content stream could not be opened- See Also:
-