Package org.springframework.core.io
Class InputStreamResource
java.lang.Object
org.springframework.core.io.AbstractResource
org.springframework.core.io.InputStreamResource
- All Implemented Interfaces:
- InputStreamSource,- Resource
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.
- Since:
- 28.12.2003
- Author:
- Juergen Hoeller, Sam Brannen
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionInputStreamResource(InputStream inputStream) Create a new InputStreamResource.InputStreamResource(InputStream inputStream, String description) Create a new InputStreamResource.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanThis implementation compares the underlying InputStream.booleanexists()This implementation always returnstrue.This implementation returns a description that includes the passed-in description, if any.This implementation throws IllegalStateException if attempting to read the underlying stream multiple times.inthashCode()This implementation returns the hash code of the underlying InputStream.booleanisOpen()This implementation always returnstrue.Methods inherited from class org.springframework.core.io.AbstractResourcecontentLength, createRelative, getFile, getFileForLastModifiedCheck, getFilename, getURI, getURL, isFile, isReadable, lastModified, readableChannel, toString
- 
Constructor Details- 
InputStreamResourceCreate a new InputStreamResource.- Parameters:
- inputStream- the InputStream to use
 
- 
InputStreamResourceCreate a new InputStreamResource.- Parameters:
- inputStream- the InputStream to use
- description- where the InputStream comes from
 
 
- 
- 
Method Details- 
existspublic boolean exists()This implementation always returnstrue.- Specified by:
- existsin interface- Resource
- Overrides:
- existsin class- AbstractResource
 
- 
isOpenpublic boolean isOpen()This implementation always returnstrue.- Specified by:
- isOpenin interface- Resource
- Overrides:
- isOpenin class- AbstractResource
 
- 
getInputStreamThis implementation throws IllegalStateException if attempting to read the underlying stream multiple times.- Returns:
- the input stream for the underlying resource (must not be null)
- Throws:
- FileNotFoundException- if the underlying resource does not exist
- IOException- if the content stream could not be opened
- IllegalStateException
- See Also:
 
- 
getDescriptionThis implementation returns a description that includes the passed-in description, if any.- See Also:
 
- 
equalsThis implementation compares the underlying InputStream.- Overrides:
- equalsin class- AbstractResource
- See Also:
 
- 
hashCodepublic int hashCode()This implementation returns the hash code of the underlying InputStream.- Overrides:
- hashCodein class- AbstractResource
- See Also:
 
 
-