public static int compare(byte[] a,byte[] b){
  if (a == b)   return 0;
  if (a == null)   return -1;
  if (b == null)   return 1;
  int len=Math.min(a.length,b.length);
  for (int i=0; i < len; ++i) {
    int diff=a[i] - b[i];
    if (diff != 0)     return diff;
  }
  if (a.length > len)   return 1;
  if (b.length > len)   return -1;
  return 0;
}

public static int compare ( byte [ ] a , byte [ ] b ) { if ( a == b ) return 0 ; if ( a == null ) return - 1 ; if ( b == null ) return 1 ; int len = Math . min ( a . length , b . length ) ; for ( int i = 0 ; i < len ; ++ i ) { int diff = a [ i ] - b [ i ] ; if ( diff != 0 ) return diff ; } if ( a . length > len ) return 1 ; if ( b . length > len ) return - 1 ; return 0 ; }
compares two byte arrays . returns < 0 if a byte in a is less than the corresponding byte in b , or if a is shorter , or if a is null . returns > 0 if a byte in a is greater than the corresponding byte in b , or if a is longer , or if b is null . returns 0 if they are equal or both null .
