public final class Binary
extends java.lang.Object
implements java.lang.Cloneable
Instances of this class are immutable.
This class is similar in philosophy to the Collection classes, and a Binary object
can be viewed as an immutable ArrayList of bytes. The getInputStream() allows an
Iterator-like approach.
| Constructor and Description |
|---|
Binary(byte[] bytes)
Creates a new binary object from a byte array.
|
Binary(byte[] bytes,
int offset,
int length)
Creates a new binary object from a byte array.
|
Binary(java.io.InputStream in)
Creates a new binary object from a byte input stream.
|
Binary(java.lang.String base64)
Creates a new byte array from a base 64 encoded string.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone()
Creates and returns a deep copy of this object.
|
boolean |
equals(java.lang.Object obj)
Returns
true if this object and the specified object have the same property
values, and false otherwise. |
byte |
get(int index)
Returns the byte at the specified index.
|
java.io.ByteArrayInputStream |
getInputStream()
Returns an input stream that can be used to read from the internal byte array.
|
int |
hashCode()
Returns the hash code of this object based on property values.
|
boolean |
isEmpty()
Returns
true if this object contains no bytes. |
int |
size()
Returns the number of bytes in the array.
|
java.lang.String |
toBase64String()
Returns a Base64 encoded representation of the bytes in the array.
|
byte[] |
toByteArray()
Returns the bytes in the object as a
byte[] instance. |
java.lang.String |
toString()
Returns a human-readable string representation of this object.
|
static Binary |
valueOfBase64(java.lang.String s)
Returns a new
Binary object with a value represented by the specified Base64
encoded string. |
void |
writeTo(java.io.OutputStream out)
Writes the contents of this object to a stream.
|
public Binary(byte[] bytes)
bytes - the byte array to construct the object from.java.lang.NullPointerException - if the bytes parameter is null.public Binary(byte[] bytes,
int offset,
int length)
bytes - the byte array to construct the object from.offset - starting position in bufferlength - number of bytesjava.lang.NullPointerException - if the bytes parameter is null.public Binary(java.io.InputStream in)
throws java.io.IOException
The caller is responsible for closing the input stream.
in - the input stream to read the bytes from.java.io.IOException - if an I/O error occurs when reading the byte stream.public Binary(java.lang.String base64)
base64 - a Base64 encoded string.public static Binary valueOfBase64(java.lang.String s)
Binary object with a value represented by the specified Base64
encoded string.s - a Base64 encoded string.Binary value representing the string.toBase64String()public byte get(int index)
index - the index of the byte to retrieve.java.lang.IndexOutOfBoundsException - if the given index is out of range (index < 0 || index >= size()).public int size()
public boolean isEmpty()
true if this object contains no bytes.true if this object contains no bytes.public byte[] toByteArray()
byte[] instance.
Note that this method performs a deep copy of the bytes.
byte[] instance.public java.io.ByteArrayInputStream getInputStream()
public boolean equals(java.lang.Object obj)
true if this object and the specified object have the same property
values, and false otherwise.equals in class java.lang.Objectobj - the object to test for equality.true if this object and the specified object have the same property
values, and false otherwise.public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.Object clone()
clone in class java.lang.ObjectCloneablepublic java.lang.String toBase64String()
public void writeTo(java.io.OutputStream out)
throws java.io.IOException
out.write(binary.toByteArray()), except that it doesn't involve copying the
array.out - the output stream to write to.java.io.IOException - if an I/O error prevented us from writing to the stream.Kofax RPA Java API, v11.5.17