org.springframework.core.io

Class 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 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