Java Utililty Methods Byte Array Equal

List of utility methods to do Byte Array Equal

Description

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

Method

booleanbyteArrayEquals(byte[] a1, byte[] a2)
Compare two byte arrays for equality
return byteArrayEquals(a1, 0, a2, 0, a1 == null ? 0 : a1.length);
booleanbyteArrayEquals(byte[] b1, byte[] b2)
byte Array Equals
if (b1 != null && b2 != null && b1.length == b2.length) {
    for (int i = 0; i < b1.length; i++) {
        if (b1[i] != b2[i])
            return false;
    return true;
} else {
    return false;
...
booleanbyteArrayEquals(final byte[] actual, final byte[] expected)
byte Array Equals
if (actual != null && expected != null && actual.length == expected.length) {
    for (int index = 0; index < actual.length; ++index) {
        if (actual[index] != expected[index]) {
            return false;
    return true;
return false;
booleanbyteArrayEquals(final byte[] lhs, final byte[] rhs)
check that two byte arrays are equal.
if (lhs == null && rhs != null || lhs != null && rhs == null) {
    return false;
if (lhs == rhs) {
    return true;
if (lhs.length != rhs.length) {
    return false;
...
booleanbyteArraysEqual(byte[] b1, byte[] b2)
Determine if two byte arrays are equal
return Arrays.equals(b1, b2);
booleanbytesEqual(byte[] a, byte[] b)
Compares two byte arrays for equality.
if (a == b) {
    return true;
if (a == null || b == null) {
    return false;
if (a.length != b.length) {
    return false;
...
booleanbytesEqual(byte[] a, byte[] b, int len)
bytes Equal
if (a == null && b == null)
    return true;
if (a == null || b == null)
    return false;
if (a.length < len || b.length < len)
    return false;
for (int i = 0; i < len; i++)
    if (a[i] != b[i])
...
booleanbytesEqual(byte[] a, int aFrom, int aLen, byte[] b, int bFrom, int bLen)
bytes Equal
if (aLen != bLen) {
    return false;
for (int i = 0; i < aLen; i++) {
    if (a[aFrom + i] != b[bFrom + i]) {
        return false;
return true;
booleanbytesEqual(byte[] a, int aOff, byte[] b, int bOff, int len)
Compares fragments of byte arrays.
if (aOff + len > a.length || bOff + len > b.length)
    return false;
else {
    for (int i = 0; i < len; i++)
        if (a[aOff + i] != b[bOff + i])
            return false;
    return true;
booleanbytesEqual(byte[] a1, byte[] a2)
Test two byte arrays for (deep) equality.
if (a1 == a2) {
    return true;
} else if (a1 == null || a2 == null) {
    return false;
} else if (a1.length != a2.length) {
    return false;
} else {
    for (int i = 0; i < a1.length; i++)
...