Package gov.usgs.earthquake.product
Class ByteContent
- java.lang.Object
-
- gov.usgs.earthquake.product.AbstractContent
-
- gov.usgs.earthquake.product.ByteContent
-
- All Implemented Interfaces:
Content
public class ByteContent extends AbstractContent
Content stored in a byte array.
-
-
Constructor Summary
Constructors Constructor Description ByteContent(byte[] content)Default constructor accepts a byte array.ByteContent(Content content)Convert any Content into ByteContent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Free any resources associated with this content.byte[]getByteArray()java.io.InputStreamgetInputStream()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 Detail
-
ByteContent
public ByteContent(byte[] content)
Default constructor accepts a byte array.- Parameters:
content- the actual content. This should not be null.
-
ByteContent
public ByteContent(Content content) throws java.io.IOException
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:
java.io.IOException- when errors occur reading content.
-
-
Method Detail
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOExceptionDescription copied from interface:ContentThe content bytes as a stream.- Returns:
- a ByteArrayInputStream for the wrapped content.
- Throws:
java.io.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.
-
-