Here you can find the source of bytesCompare(byte[] bytes1, byte[] bytes2)
public static int bytesCompare(byte[] bytes1, byte[] bytes2)
//package com.java2s; //License from project: Apache License public class Main { public static int bytesCompare(byte[] bytes1, byte[] bytes2) { if (bytes1 == bytes2) { return 0; }//from ww w. ja va 2 s .co m int len1 = bytes1.length; int len2 = bytes2.length; int len = len1 < len2 ? len1 : len2; for (int i = 0; i < len; i++) { int a = (bytes1[i] & 0xff); int b = (bytes2[i] & 0xff); if (a != b) { return a - b; } } return 0; } }