Class InputStreamContent

java.lang.Object
gov.usgs.earthquake.product.AbstractContent
gov.usgs.earthquake.product.InputStreamContent
All Implemented Interfaces:
Content

public class InputStreamContent extends AbstractContent
Content within an InputStream.
  • Constructor Details

    • InputStreamContent

      public InputStreamContent(InputStream content)
      Create a new InputStream content.
      Parameters:
      content - the content.
    • InputStreamContent

      public InputStreamContent(Content content) throws IOException
      Create an InputStreamContent from another Content.
      Parameters:
      content - the content to duplicate.
      Throws:
      IOException - if IO error occurs
  • Method Details

    • getInputStream

      public InputStream getInputStream() throws IOException
      Description copied from interface: Content
      The content bytes as a stream.
      Returns:
      InputStream to content.
      Throws:
      IOException - if an error occurs while creating the stream.
    • getSha256

      public String getSha256() throws Exception
      InputStream can only be read once.

      If sha256 is null, read and convert to in memory stream.

      Specified by:
      getSha256 in interface Content
      Overrides:
      getSha256 in class AbstractContent
      Returns:
      base64 encoded sha256 of content bytes.
      Throws:
      Exception - if error occurs
    • close

      public void close()
      Free any resources associated with this content.