Java Array Start With startWith(byte[] startWith, byte[] bytes)

Here you can find the source of startWith(byte[] startWith, byte[] bytes)

Description

start With

License

Apache License

Parameter

Parameter Description
startWith The bytes to start with
bytes The bytes to test

Declaration

public static boolean startWith(byte[] startWith, byte[] bytes) 

Method Source Code

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

public class Main {
    /**/*from  w w  w.j a v  a  2 s .c  o  m*/
     * 
     * @param startWith The bytes to start with
     * @param bytes The bytes to test
     * @return
     */
    public static boolean startWith(byte[] startWith, byte[] bytes) {
        if (bytes == null || startWith == null || bytes.length < startWith.length) {
            return false;
        }

        for (int i = 0; i < startWith.length; i++) {
            if (bytes[i] != startWith[i]) {
                return false;
            }
        }
        return true;
    }
}

Related

  1. arrayStartsWith(byte[] a, byte[] b)
  2. arrayStartsWith(byte[] array, byte[] target)
  3. arrayStartsWith(final byte[] array, final byte[] str)
  4. arrayStartsWith(V[] pattern, V[] data)
  5. startWith(byte[] data, int start, byte[] find)
  6. startWith(char[] value, char c)
  7. startWith(final byte[] aBuffer, final byte[] aPrefix)
  8. startWith(String t, String[] prefix)