Java Array Starts With startsWith(byte[] prefix, byte[] source)

Here you can find the source of startsWith(byte[] prefix, byte[] source)

Description

returns whether the source array starts with the prefix array

License

Open Source License

Parameter

Parameter Description
prefix the byte array containing the prefix
source the byte array of the source

Declaration

private static boolean startsWith(byte[] prefix, byte[] source) 

Method Source Code

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

public class Main {
    /** returns whether the source array starts with the prefix array
     * @param prefix the byte array containing the prefix
     * @param source the byte array of the source
     *//*from w  ww .  j ava 2s.c  o  m*/
    private static boolean startsWith(byte[] prefix, byte[] source) {
        if (prefix.length > source.length) {
            return false;
        } else {
            for (int i = 0; i < prefix.length; i++) {
                if (prefix[i] != source[i]) {
                    return false;
                }
            }
            return true;
        }
    }
}

Related

  1. startsWith(byte[] bytes, String text)
  2. startsWith(byte[] checkMe, byte[] maybePrefix)
  3. startsWith(byte[] haystack, byte[] needle)
  4. startsWith(byte[] nameRaw, byte[] namePrefix)
  5. startsWith(byte[] p, byte id)
  6. startsWith(byte[] source, byte[] match)
  7. startsWith(byte[] source, byte[] match)
  8. startsWith(byte[] source, int offset, byte[] match)
  9. startsWith(byte[] target, byte[] search, int offset)