Java Array Start With arrayStartsWith(byte[] a, byte[] b)

Here you can find the source of arrayStartsWith(byte[] a, byte[] b)

Description

array Starts With

License

Open Source License

Declaration

public static boolean arrayStartsWith(byte[] a, byte[] b) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static boolean arrayStartsWith(byte[] a, byte[] b) {
        return rangeEquals(a, 0, b, 0, b.length);
    }// www . ja v  a2  s.  c o  m

    public static boolean rangeEquals(byte[] a, int aStart, byte[] b, int bStart, int length) {
        assert a.length - aStart > length && b.length - bStart > length;

        for (int i = aStart, j = bStart, k = 0; k < length; k++) {
            if (a[i] != b[j])
                return false;
        }

        return true;
    }
}

Related

  1. arrayStartsWith(byte[] array, byte[] target)
  2. arrayStartsWith(final byte[] array, final byte[] str)
  3. arrayStartsWith(V[] pattern, V[] data)
  4. startWith(byte[] data, int start, byte[] find)