are Byte Arrays Equal - Android File Input Output

Android examples for File Input Output:Byte Array

Description

are Byte Arrays Equal

Demo 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   ww  w  .  ja v a  2s.c o  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 Tutorials