Java Byte Array Compare bytesCompare(byte[] a, byte[] b)

Here you can find the source of bytesCompare(byte[] a, byte[] b)

Description

Compare 2 byte arrays byte to byte

License

Open Source License

Parameter

Parameter Description
a byte[]
b byte[]

Return

boolean

Declaration

public static boolean bytesCompare(byte[] a, byte[] b) 

Method Source Code

//package com.java2s;
/*//from w  ww .  j a  va2 s  .  c o m
 * Java Bittorrent API as its name indicates is a JAVA API that implements the Bittorrent Protocol
 * This project contains two packages:
 * 1. jBittorrentAPI is the "client" part, i.e. it implements all classes needed to publish
 *    files, share them and download them.
 *    This package also contains example classes on how a developer could create new applications.
 * 2. trackerBT is the "tracker" part, i.e. it implements a all classes needed to run
 *    a Bittorrent tracker that coordinates peers exchanges. *
 *
 * Copyright (C) 2007 Baptiste Dubuis, Artificial Intelligence Laboratory, EPFL
 *
 * This file is part of jbittorrentapi-v1.0.zip
 *
 * Java Bittorrent API is free software and a free user study set-up;
 * you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Java Bittorrent API is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Java Bittorrent API; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @version 1.0
 * @author Baptiste Dubuis
 * To contact the author:
 * email: baptiste.dubuis@gmail.com
 *
 * More information about Java Bittorrent API:
 *    http://sourceforge.net/projects/bitext/
 */

public class Main {
    /**
     * Compare 2 byte arrays byte to byte
     * @param a byte[]
     * @param b byte[]
     * @return boolean
     */
    public static boolean bytesCompare(byte[] a, byte[] b) {
        if (a.length != b.length)
            return false;
        for (int i = 0; i < a.length; i++)
            if (a[i] != b[i])
                return false;
        return true;
    }
}

Related

  1. allEquals(byte[] array, byte value, int offset, int maxLength)
  2. ArrayByteCompare(byte[] a, byte[] b)
  3. bytesCmp(byte[] oi, byte[] oj)
  4. bytesCompare(byte[] a, byte[] b)
  5. bytesCompare(byte[] bytes1, byte[] bytes2)
  6. memcmp(byte a[], int a_off, byte b[], int b_off, int len)
  7. memcmp(byte[] a, byte[] b)
  8. memcmp(byte[] a, int a_offset, byte[] b, int b_offset, int length)