public class BinaryContentImpl extends Object implements BinaryContent
BinaryContent interface.| Constructor and Description |
|---|
BinaryContentImpl(InputStream inputStream)
Instantiates a new product resource.
|
BinaryContentImpl(InputStream inputStream,
MimeType mimeType)
Instantiates a new product resource.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getByteArray()
Convenience method to attempt to read the contents of the
InputStream into a
byte array. |
InputStream |
getInputStream()
Gets the input stream.
|
MimeType |
getMimeType() |
String |
getMimeTypeValue()
|
long |
getSize()
Get the size if known.
|
void |
setSize(long size)
Sets the size in bytes of the binary content.
|
String |
toString()
String representation of this
BinaryContentImpl. |
public BinaryContentImpl(InputStream inputStream, MimeType mimeType)
inputStream - the input streammimeType - the mime type for the resourcepublic BinaryContentImpl(InputStream inputStream)
inputStream - the input streampublic InputStream getInputStream()
BinaryContentNote that the binary from the InputStream can only be accessed once. Thus, when
you call BinaryContent.getInputStream() and retrieve the InputStream object, it can
only be used once to extract the content. If it is necessary that the bytes of the
InputStream object are needed again, use the BinaryContent.getByteArray() method instead.
getInputStream in interface BinaryContentpublic MimeType getMimeType()
getMimeType in interface BinaryContentInputStreampublic String getMimeTypeValue()
BinaryContentgetMimeTypeValue in interface BinaryContentStringpublic String toString()
BinaryContentImpl.public long getSize()
BinaryContentgetSize in interface BinaryContentlong, -1 if unknownpublic void setSize(long size)
size - public byte[] getByteArray()
throws IOException
BinaryContentInputStream into a
byte array.
Note that BinaryContent.getByteArray() should be idempotent if BinaryContent.getInputStream() has not
been initially invoked.
getByteArray in interface BinaryContentIOException - if the stream can not be read into the arrayThis work is licensed under a Creative Commons Attribution 4.0 International License.