Here you can find the source of memcmp(final byte[] a, final byte[] b, int length)
public static int memcmp(final byte[] a, final byte[] b, int length)
//package com.java2s; //License from project: Open Source License public class Main { public static int memcmp(final byte[] a, final byte[] b) { final int length = Math.min(a.length, b.length); if (a == b) { // Do this after accessing a.length and b.length return 0; // in order to NPE if either a or b is null. }//from w w w . ja v a 2 s . co m for (int i = 0; i < length; i++) { if (a[i] != b[i]) { return (a[i] & 0xFF) - (b[i] & 0xFF); } } return a.length - b.length; } public static int memcmp(final byte[] a, final byte[] b, int length) { for (int i = 0; i < length; i++) { if (a[i] != b[i]) { return (a[i] & 0xFF) - (b[i] & 0xFF); } } return 0; } public static int memcmp(final byte[] a, final byte[] b, int off, int length) { for (int i = 0; i < length; i++) { if (a[i] != b[i + off]) { return (a[i] & 0xFF) - (b[i + off] & 0xFF); } } return 0; } }