public static int compareNotNull(byte[] data1,byte[] data2){
  if (data1 == data2) {
    return 0;
  }
  int len=Math.min(data1.length,data2.length);
  for (int i=0; i < len; i++) {
    int b=data1[i] & 255;
    int b2=data2[i] & 255;
    if (b != b2) {
      return b > b2 ? 1 : -1;
    }
  }
  return Integer.signum(data1.length - data2.length);
}

public static int compareNotNull ( byte [ ] data1 , byte [ ] data2 ) { if ( data1 == data2 ) { return 0 ; } int len = Math . min ( data1 . length , data2 . length ) ; for ( int i = 0 ; i < len ; i ++ ) { int b = data1 [ i ] & 255 ; int b2 = data2 [ i ] & 255 ; if ( b != b2 ) { return b > b2 ? 1 : - 1 ; } } return Integer . signum ( data1 . length - data2 . length ) ; }
compare the contents of two byte arrays . if the content or length of the first array is smaller than the second array , - 1 is returned . if the content or length of the second array is smaller than the first array , 1 is returned . if the contents and lengths are the same , 0 is returned . < p > this method interprets bytes as unsigned .
