Top Description Methods
org.springframework.core.io

public Interface InputStreamSource

Known Direct Subinterfaces
org.springframework.core.io.Resource
Known Direct Implementers
org.springframework.core.io.support.EncodedResource, org.springframework.aot.generate.AppendableConsumerInputStreamSource
Imports
java.io.IOException, .InputStream

Simple interface for objects that are sources for an 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.

Author
Juergen Hoeller
Since
20.01.2004
See Also
java.io.InputStream, Resource, InputStreamResource, ByteArrayResource

Method Summary

Modifier and TypeMethod and Description
public InputStream

Returns:

the input stream for the underlying resource (must not be null)
getInputStream
()

Return an InputStream for the content of an underlying resource.

Method Detail

getInputStreamback to summary
public InputStream getInputStream() throws IOException

Return an InputStream 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.

Returns:InputStream

the input stream for the underlying resource (must not be null)

Exceptions
IOException:
if the content stream could not be opened
FileNotFoundException:
if the underlying resource does not exist
See Also
Resource#isReadable()