Here you can find the source of indexOf(byte[] target, byte[] key)
public static int indexOf(byte[] target, byte[] key)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { public static int indexOf(byte[] target, byte[] key) { return indexOf(target, key, 0); }/*from www. java 2 s. com*/ public static int indexOf(byte[] target, byte[] key, int from) { int result = -1; for (int i = from; i + key.length < target.length; i++) { if (Arrays.equals(Arrays.copyOfRange(target, i, i + key.length), key)) { result = i; break; } } return result; } public static int indexOf(byte[] target, byte key) { return indexOf(target, new byte[] { key }); } public static int indexOf(byte[] target, byte key, int from) { return indexOf(target, new byte[] { key }, from); } }