Here you can find the source of indexOf(ByteBuffer buffer, byte b)
public static int indexOf(ByteBuffer buffer, byte b)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static int indexOf(ByteBuffer buffer, byte b) { return indexOf(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining(), b); }//from www.j a v a 2 s .co m public static int indexOf(byte[] data, byte b) { return indexOf(data, 0, data.length, b); } public static int indexOf(byte[] data, int offset, int length, byte b) { int idx = -1; for (int i = offset; i < offset + length; i++) { if (data[i] == b) { idx = i; break; } } return idx; } }