Java Utililty Methods Byte Array And

List of utility methods to do Byte Array And

Description

The list of methods to do Byte Array And are organized into topic(s).

Method

byte[]and(byte[] a, byte[] b)
a & b
if (a == null)
    throw new IllegalArgumentException("a should not be null");
if (b == null)
    throw new IllegalArgumentException("b should not be null");
if (a.length != b.length)
    throw new IllegalArgumentException("byte array length should be same");
int len = a.length;
byte[] result = new byte[len];
...
byte[]and(byte[] a, byte[] b)
and
byte[] dst = new byte[a.length];
and(a, 0, b, 0, dst, 0, dst.length);
return dst;
byte[]and(byte[] a, byte[] b)
and
if (a.length != b.length) {
    throw new IllegalArgumentException("Arrays a and b should have equal length");
byte[] result = new byte[a.length];
for (int i = 0; i < a.length; i++) {
    result[i] = (byte) (a[i] & b[i]);
return result;
...
voidand(byte[] a, int offsetA, byte[] b, int offsetB, byte[] dst, int dstOffset, int length)
AND length number of bytes from a with b using the syntax ( a[i] & b[i] ) and store the result in dst
for (int i = 0, aI = offsetA, bI = offsetB, dstI = dstOffset; i < length; i++, aI++, bI++, dstI++) {
    dst[dstI] = (byte) (a[aI] & b[bI]);
byte[]and(byte[] data1, byte[] data2)
and
if (data1.length != data2.length) {
    throw new IllegalArgumentException(
            "array lenth does NOT match, " + data1.length + " vs " + data2.length);
final byte r[] = new byte[data1.length];
for (int i = 0; i < r.length; i++) {
    r[i] = (byte) (data1[i] & data2[i]);
return r;