Here you can find the source of byteArrayEquals(final byte[] lhs, final byte[] rhs)
Parameter | Description |
---|---|
lhs | a byte array |
rhs | another byte array. |
true
if they are both equal (or both null
)
public static boolean byteArrayEquals(final byte[] lhs, final byte[] rhs)
//package com.java2s; //License from project: Apache License public class Main { /** check that two byte arrays are equal. They may be <code>null</code>. *// ww w .jav a 2 s .co m * @param lhs a byte array * @param rhs another byte array. * @return <code>true</code> if they are both equal (or both * <code>null</code>) */ public static boolean byteArrayEquals(final byte[] lhs, final byte[] rhs) { if (lhs == null && rhs != null || lhs != null && rhs == null) { return false; } if (lhs == rhs) { return true; } if (lhs.length != rhs.length) { return false; } for (int i = 0; i < lhs.length; i++) { if (lhs[i] != rhs[i]) { return false; } } return true; } }