Java Array Start With arrayStartsWith(byte[] array, byte[] target)

Here you can find the source of arrayStartsWith(byte[] array, byte[] target)

Description

Checks if array starts with target.

License

Open Source License

Declaration

static boolean arrayStartsWith(byte[] array, byte[] target) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

public class Main {
    /** Checks if array starts with target. */
    static boolean arrayStartsWith(byte[] array, byte[] target) {
        if (array == null) {
            return false;
        }//from w ww.ja va2 s  . com
        if (target == null) {
            return true;
        }
        if (target.length > array.length) {
            return false;
        }
        for (int i = 0; i < target.length; i++) {
            if (array[i] != target[i]) {
                return false;
            }
        }
        return true;
    }
}

Related

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