Java tutorial
//package com.java2s; public class Main { public static int indexOf(byte[] datas, int start, byte[] t) { if (datas == null || t == null) { throw new NullPointerException("source or target array is null!"); } int index = -1; int len = datas.length; int tlen = t.length; if (start >= len || len - start < tlen) { return -1; } while (start <= len - tlen) { int i = 0; for (; i < tlen; i++) { if (datas[start + i] != t[i]) { break; } } if (i == tlen) { index = start; break; } start++; } return index; } }