Java Array Starts With startsWith(byte a[], int from, byte b[])

Here you can find the source of startsWith(byte a[], int from, byte b[])

Description

starts With

License

Apache License

Declaration

static public boolean startsWith(byte a[], int from, byte b[]) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    static public int startsWith(String s, String prefix[]) {
        if (s == null || prefix == null)
            return -1;
        for (int i = 0; i < prefix.length; i++) {
            if (s.startsWith(prefix[i]))
                return i;
        }/*from w w w .j  av  a2  s. c om*/
        return -1;
    }

    static public boolean startsWith(byte a[], int from, byte b[]) {
        final int nb = b.length;
        for (int i = 0; i < nb; i++) {
            final int j = from + i;
            if (j >= a.length || a[j] != b[i])
                return false;
        }
        return true;
    }
}

Related

  1. startsWith(byte[] arr, int offset, int len, byte[] pattern)
  2. startsWith(byte[] array, byte[] prefix)
  3. startsWith(byte[] array, byte[] startBytes)
  4. startsWith(byte[] bytes, int offset, byte... prefix)