站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.0.5 API 文档英文版

InputStreamResource (Spring Framework API 2.0) - Spring Framework 2.0.5 API 文档英文版

The Spring Framework

org.springframework.core.io
Class InputStreamResource

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

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.

Since:
28.12.2003
Author:
Juergen Hoeller
See Also:
ByteArrayResource, ClassPathResource, FileSystemResource, UrlResource

Constructor Summary
InputStreamResource(InputStream inputStream)
          Create a new InputStreamResource.
InputStreamResource(InputStream inputStream, String description)
          Create a new InputStreamResource.
 
Method Summary
 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.
 
Methods inherited from class org.springframework.core.io.AbstractResource
createRelative, getFile, getFilename, getURL, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InputStreamResource

public InputStreamResource(InputStream inputStream)
Create a new InputStreamResource.

Parameters:
inputStream - the InputStream to use

InputStreamResource

public InputStreamResource(InputStream inputStream,
                           String description)
Create a new InputStreamResource.

Parameters:
inputStream - the InputStream to use
description - where the InputStream comes from
Method Detail

exists

public boolean exists()
This implementation always returns true.

Specified by:
exists in interface Resource
Overrides:
exists in class AbstractResource

isOpen

public boolean isOpen()
This implementation always returns true.

Specified by:
isOpen in interface Resource
Overrides:
isOpen in class AbstractResource

getInputStream

public InputStream getInputStream()
                           throws IOException,
                                  IllegalStateException
This implementation throws IllegalStateException if attempting to read the underlying stream multiple times.

Throws:
IOException - if the stream could not be opened
IllegalStateException
See Also:
MimeMessageHelper.addAttachment(String, InputStreamSource)

getDescription

public String getDescription()
This implementation returns the passed-in description, if any.

Specified by:
getDescription in interface Resource
Specified by:
getDescription in class AbstractResource
See Also:
Resource.getDescription(), AbstractResource.toString(), AbstractResource.equals(Object), AbstractResource.hashCode()

equals

public boolean equals(Object obj)
This implementation compares the underlying InputStream.

Overrides:
equals in class AbstractResource
See Also:
AbstractResource.getDescription()

hashCode

public int hashCode()
This implementation returns the hash code of the underlying InputStream.

Overrides:
hashCode in class AbstractResource
See Also:
AbstractResource.getDescription()

The Spring Framework

Copyright © 2002-2007 The Spring Framework.