public class InputStreamResource extends AbstractResource
Resource
implementation for a given InputStream. Should only
be used if no 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 it if you need to keep the resource
descriptor somewhere, or if you need to read a stream multiple times.
ByteArrayResource
,
ClassPathResource
,
FileSystemResource
,
UrlResource
构造器和说明 |
---|
InputStreamResource(InputStream inputStream)
Create a new InputStreamResource.
|
InputStreamResource(InputStream inputStream,
String description)
Create a new InputStreamResource.
|
限定符和类型 | 方法和说明 |
---|---|
boolean |
equals(Object obj)
This implementation compares the underlying InputStream.
|
boolean |
exists()
This implementation always returns
true . |
String |
getDescription()
This implementation returns the passed-in description, if any.
|
InputStream |
getInputStream()
This implementation throws IllegalStateException if attempting to
read the underlying stream multiple times.
|
int |
hashCode()
This implementation returns the hash code of the underlying InputStream.
|
boolean |
isOpen()
This implementation always returns
true . |
contentLength, createRelative, getFile, getFileForLastModifiedCheck, getFilename, getURI, getURL, isReadable, lastModified, toString
public InputStreamResource(InputStream inputStream)
inputStream
- the InputStream to usepublic InputStreamResource(InputStream inputStream, String description)
inputStream
- the InputStream to usedescription
- where the InputStream comes frompublic boolean exists()
true
.exists
在接口中 Resource
exists
在类中 AbstractResource
public boolean isOpen()
true
.isOpen
在接口中 Resource
isOpen
在类中 AbstractResource
public InputStream getInputStream() throws IOException, IllegalStateException
null
)IOException
- if the stream could not be opened
·IllegalStateException
public String getDescription()
Object.toString()
public boolean equals(Object obj)
equals
在类中 AbstractResource
Resource.getDescription()
public int hashCode()
hashCode
在类中 AbstractResource
Resource.getDescription()
Copyright © 2018 jretty-org. All rights reserved.