Java Array Equal bytesAreEqual(byte[] b1, byte[] b2)

Here you can find the source of bytesAreEqual(byte[] b1, byte[] b2)

Description

Compares two byte arrays returning true if they're equal in length and content false if they're not.

License

Open Source License

Parameter

Parameter Description
b1 the first byte array.
b2 the second byte array.

Return

true if the arrays are equal, false if they are not.

Declaration

public static boolean bytesAreEqual(byte[] b1, byte[] b2) 

Method Source Code

//package com.java2s;
/*/*  w  w w . ja  va2  s. c om*/
 * $Id$
 * 
 * Copyright (c) 2008-2014 David Muller <roxon@users.sourceforge.net>.
 * All rights reserved. Use of the code is allowed under the
 * Artistic License 2.0 terms, as specified in the LICENSE file
 * distributed with this code, or available from
 * http://www.opensource.org/licenses/artistic-license-2.0.php
 */

import java.util.Arrays;

public class Main {
    /**
     * Compares two byte arrays returning <code>true</code> if they're equal in
     * length and content <code>false</code> if they're not.
     * 
     * @param b1 the first byte array.
     * @param b2 the second byte array.
     * 
     * @return <code>true</code> if the arrays are equal, <code>false</code> if
     *         they are not.
     */
    public static boolean bytesAreEqual(byte[] b1, byte[] b2) {
        return Arrays.equals(b1, b2);
    }
}

Related

  1. arraysEquals(byte[] a, byte[] b)
  2. arraysEquals(byte[] a, int ofsA, byte[] b, int ofsB, int len)
  3. arraysEquals(byte[] arr1, int offset1, byte[] arr2, int offset2)
  4. arraysEquals(Object[] mThis, Object[] mThat)
  5. blobsAreEqual(byte[] blob1, byte[] blob2)
  6. equal(boolean[][] a, boolean[][] b)
  7. equal(byte[] a, byte[] b)
  8. equal(float[][] array1, float[][] array2)
  9. equal(int[] a, int[] b)