Java tutorial
//package com.java2s; import android.util.Log; public class Main { public static int indexOfBAIndex(byte[] data) { int index = 0; for (int i = 0; i < data.length; i++) { if (data[i] == (byte) 0xBA) { if (i < (data.length - 1)) { if (data[i + 1] == (byte) 0xBA) { index = i; break; } } } } Log.e("BMSUtil", "contain the BA indexAt:" + index); return index; } }