Here you can find the source of indexof(byte[] shortBytes, byte[] longBytes)
public static int indexof(byte[] shortBytes, byte[] longBytes)
//package com.java2s; public class Main { public static int indexof(byte[] shortBytes, byte[] longBytes) { for (int i = 0; i < longBytes.length; i++) { if (longBytes[i] == shortBytes[0] && longBytes.length - i >= shortBytes.length) { boolean isIndexof = true; for (int j = 1; j < shortBytes.length; j++) { if (shortBytes[j] != longBytes[i + j]) { isIndexof = false; continue; }//from w ww . ja v a 2s.co m } if (isIndexof) { return i; } } } return -1; } }