Class InputStreamResource

java.lang.Object
org.springframework.core.io.AbstractResource
org.springframework.core.io.InputStreamResource
All Implemented Interfaces:
InputStreamSource, Resource

public class InputStreamResource extends AbstractResource
Resource implementation for a given InputStream or a given InputStreamSource (which can be supplied as a lambda expression) for a lazy InputStream on demand.

Should only be used if no other specific Resource implementation is applicable. In particular, prefer ByteArrayResource or any of the file-based Resource implementations if possible. If you need to obtain a custom stream multiple times, use a custom AbstractResource subclass with a corresponding getInputStream() implementation.

In contrast to other Resource implementations, this is a descriptor for an already opened resource - therefore returning true from isOpen(). Do not use an InputStreamResource if you need to keep the resource descriptor somewhere, or if you need to read from a stream multiple times. This also applies when constructed with an InputStreamSource which lazily obtains the stream but only allows for single access as well.

Since:
28.12.2003
Author:
Juergen Hoeller, Sam Brannen
See Also: