Here you can find the source of startsWith(byte[] bytes, int offset, byte... prefix)
public static boolean startsWith(byte[] bytes, int offset, byte... prefix)
//package com.java2s; //License from project: Apache License public class Main { public static boolean startsWith(byte[] bytes, int offset, byte... prefix) { if (length(bytes) == 0 || length(prefix) == 0 || prefix.length > bytes.length || offset < 0 || offset + prefix.length > bytes.length) { return false; }//from w ww . j av a 2 s.c o m for (int i = 0; i < prefix.length; i++) { if (prefix[i] != bytes[i + offset]) { return false; } } return true; } public static int length(byte[] array) { return (array == null ? 0 : array.length); } public static int length(byte[]... arrays) { int len = 0; if (arrays != null) { for (byte[] array : arrays) { if (array != null) { len += array.length; } } } return len; } }