Package gov.usgs.earthquake.product
Class ByteContent
java.lang.Object
gov.usgs.earthquake.product.AbstractContent
gov.usgs.earthquake.product.ByteContent
- All Implemented Interfaces:
Content
Content stored in a byte array.
-
Constructor Summary
ConstructorsConstructorDescriptionByteContent
(byte[] content) Default constructor accepts a byte array.ByteContent
(Content content) Convert any Content into ByteContent. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Free any resources associated with this content.byte[]
The content bytes as a stream.Methods inherited from class gov.usgs.earthquake.product.AbstractContent
getContentType, getLastModified, getLength, getSha256, getSha256, setContentType, setLastModified, setLength, setSha256
-
Constructor Details
-
ByteContent
public ByteContent(byte[] content) Default constructor accepts a byte array.- Parameters:
content
- the actual content. This should not be null.
-
ByteContent
Convert any Content into ByteContent. Any content is read from the InputStream into a new underlying byte array.- Parameters:
content
- existing content to read.- Throws:
IOException
- when errors occur reading content.
-
-
Method Details
-
getInputStream
Description copied from interface:Content
The content bytes as a stream.- Returns:
- a ByteArrayInputStream for the wrapped content.
- Throws:
IOException
- if an error occurs while creating the stream.
-
getByteArray
public byte[] getByteArray()- Returns:
- the wrapped byte array.
-
close
public void close()Free any resources associated with this content.
-