Java Utililty Methods Byte Array Compare

List of utility methods to do Byte Array Compare

  1. HOME
  2. Java
  3. B
  4. Byte Array Compare

Description

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

Method

boolean allEquals(byte[] array, byte value, int offset, int maxLength)
all Equals
maxLength = Math.min(offset + maxLength, array.length);
for (int i = offset; i < maxLength; i++) {
 if (array[i] != value) {
 return false;
return true;
boolean ArrayByteCompare(byte[] a, byte[] b)
Array Byte Compare
boolean ret = true;
if (a.length == b.length) {
 for (int i = 0; i < a.length; i++) {
 if (a[i] != b[i]) {
 ret = false;
 break;
} else {
 ret = false;
return ret;
boolean bytesCmp(byte[] oi, byte[] oj)
bytes Cmp
if (oi.length - oj.length != 0)
 return false;
for (int i = 0; i < oi.length; i++) {
 if (oi[i] != oj[i])
 return false;
return true;
boolean bytesCompare(byte[] a, byte[] b)
Compare 2 byte arrays byte to byte
if (a.length != b.length)
 return false;
for (int i = 0; i < a.length; i++)
 if (a[i] != b[i])
 return false;
return true;
int bytesCompare(byte[] a, byte[] b)
bytes Compare
if (null == a && null == b)
 return 0;
if (null == a && null != b)
 return -1;
if (null != a && null == b)
 return 1;
int minLen = Math.min(a.length, b.length);
for (int i = 0; i < minLen; ++i) {
...
int bytesCompare(byte[] bytes1, byte[] bytes2)
bytes Compare
if (bytes1 == bytes2) {
 return 0;
int len1 = bytes1.length;
int len2 = bytes2.length;
int len = len1 < len2 ? len1 : len2;
for (int i = 0; i < len; i++) {
 int a = (bytes1[i] & 0xff);
...
int memcmp(byte a[], int a_off, byte b[], int b_off, int len)
memcmp
for (; len-- > 0; a_off++, b_off++)
 if (a[a_off] != b[b_off])
 return (a[a_off] & 0xff) - (b[b_off] & 0xff);
return 0;
int memcmp(byte[] a, byte[] b)
memcmp
int min = a.length > b.length ? b.length : a.length;
for (int i = 0; i < min; i++)
 if (a[i] < b[i])
 return -1;
 else if (a[i] > b[i])
 return 1;
return a.length - b.length;
boolean memcmp(byte[] a, int a_offset, byte[] b, int b_offset, int length)
Compare the contents of one array of bytes to another.
if ((a == null) && (b == null)) {
 return true;
if ((a == null) || (b == null)) {
 return false;
for (int i = 0; i < length; ++i, ++a_offset, ++b_offset)
 if (a[a_offset] != b[b_offset]) {
...
int memcmp(byte[] a, int aoff, int alen, byte[] b, int boff, int blen)
memcmp
int result;
if (alen < blen)
 result = -1;
else if (alen > blen)
 result = 1;
else
 result = 0;
int length = Math.min(alen, blen);
...


AltStyle によって変換されたページ (->オリジナル) /