Here you can find the source of bytesCompare(byte[] a, byte[] b)
private static int bytesCompare(byte[] a, byte[] b)
//package com.java2s; //License from project: Apache License public class Main { private static int bytesCompare(byte[] a, byte[] b) { if (null == a && null == b) return 0; if (null == a && null != b) return -1; if (null != a && null == b) return 1; int minLen = Math.min(a.length, b.length); for (int i = 0; i < minLen; ++i) { int v = (a[i] & 0xff) - (b[i] & 0xff); if (v != 0) return v; }// w w w.j a va 2 s . co m if (a.length < b.length) return -1; else if (a.length > b.length) return 1; else return 0; } }