spring-framework / org.springframework.core.io / InputStreamResource

InputStreamResource

open class InputStreamResource : AbstractResource

Resource implementation for a given InputStream.

Should only be used if no other specific Resource implementation is applicable. In particular, prefer ByteArrayResource or any of the file-based Resource implementations where possible.

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.

Author
Juergen Hoeller

Author
Sam Brannen

Since
28.12.2003

See Also
ByteArrayResourceClassPathResourceFileSystemResourceUrlResource

Constructors

<init>

InputStreamResource(inputStream: InputStream)
InputStreamResource(inputStream: InputStream, description: String)

Create a new InputStreamResource.

Functions

equals

open fun equals(other: Any?): Boolean

This implementation compares the underlying InputStream.

exists

open fun exists(): Boolean

This implementation always returns true.

getDescription

open fun getDescription(): String

This implementation returns a description that includes the passed-in description, if any.

getInputStream

open fun getInputStream(): InputStream

This implementation throws IllegalStateException if attempting to read the underlying stream multiple times.

hashCode

open fun hashCode(): Int

This implementation returns the hash code of the underlying InputStream.

isOpen

open fun isOpen(): Boolean

This implementation always returns true.