Android Byte Array Compare areByteArraysEqual(byte[] byteArray0, byte[] byteArray1)

Here you can find the source of areByteArraysEqual(byte[] byteArray0, byte[] byteArray1)

Description

are Byte Arrays Equal

License

Open Source License

Declaration

public static boolean areByteArraysEqual(byte[] byteArray0,
            byte[] byteArray1) 

Method Source Code

//package com.java2s;

public class Main {
    public static boolean areByteArraysEqual(byte[] byteArray0,
            byte[] byteArray1) {
        if (byteArray0 == null && byteArray1 != null) {
            return false;
        } else if (byteArray0 != null && byteArray1 == null) {
            return false;
        } else if (byteArray0 == null && byteArray1 == null) {
            return true;
        }//from  w  w w  .  j  a  va 2s.co  m

        if (byteArray0.length != byteArray1.length) {
            return false;
        }

        for (int i = 0; i < byteArray0.length; i++) {
            if (byteArray0[i] != byteArray1[i]) {
                return false;
            }
        }

        return true;
    }
}

Related

  1. compareSecure(byte[] test, byte[] good)
  2. compareTo(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2, int length2)
  3. compareTo(final byte[] left, final byte[] right)
  4. areEqual(byte[] a, byte[] b)
  5. compare(byte[] arr1, byte[] arr2)