Interface InputStreamSource
-
- All Known Subinterfaces:
ContextResource,Resource,WritableResource
- All Known Implementing Classes:
AbstractFileResolvingResource,AbstractResource,ClassPathResource,DefaultResourceLoader.ClassPathContextResource,FileSystemResource,InputStreamResource,PathResource,UrlResource,VfsResource
public interface InputStreamSourceSimple interface for objects that are sources for anInputStream.This is the base interface for Spring's more extensive
Resourceinterface.For single-use streams,
InputStreamResourcecan be used for any givenInputStream. Spring'sByteArrayResourceor any file-basedResourceimplementation 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:
InputStream,Resource,InputStreamResource,ByteArrayResource
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description InputStreamgetInputStream()Return anInputStream.
-
-
-
Method Detail
-
getInputStream
InputStream getInputStream() throws IOException
Return anInputStream.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.- Returns:
- the input stream for the underlying resource (must not be
null) - Throws:
IOException- if the stream could not be opened- See Also:
org.springframework.mail.javamail.MimeMessageHelper#addAttachment(String, InputStreamSource)
-
-