Package gov.usgs.earthquake.product
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 Summary
Constructors Constructor Description InputStreamContent(Content content)
Create an InputStreamContent from another Content.InputStreamContent(java.io.InputStream content)
Create a new InputStream content.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Free any resources associated with this content.java.io.InputStream
getInputStream()
The content bytes as a stream.java.lang.String
getSha256()
InputStream can only be read once.-
Methods inherited from class gov.usgs.earthquake.product.AbstractContent
getContentType, getLastModified, getLength, getSha256, setContentType, setLastModified, setLength, setSha256
-
-
-
-
Constructor Detail
-
InputStreamContent
public InputStreamContent(java.io.InputStream content)
Create a new InputStream content.- Parameters:
content
- the content.
-
InputStreamContent
public InputStreamContent(Content content) throws java.io.IOException
Create an InputStreamContent from another Content.- Parameters:
content
- the content to duplicate.- Throws:
java.io.IOException
- if IO error occurs
-
-
Method Detail
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException
Description copied from interface:Content
The content bytes as a stream.- Returns:
- InputStream to content.
- Throws:
java.io.IOException
- if an error occurs while creating the stream.
-
getSha256
public java.lang.String getSha256() throws java.lang.Exception
InputStream can only be read once.If sha256 is null, read and convert to in memory stream.
- Specified by:
getSha256
in interfaceContent
- Overrides:
getSha256
in classAbstractContent
- Returns:
- base64 encoded sha256 of content bytes.
- Throws:
java.lang.Exception
- if error occurs
-
close
public void close()
Free any resources associated with this content.
-
-