Here you can find the source of indexOf(final ByteBuffer buf, final int c, final int start, final int end)
Parameter | Description |
---|---|
buf | the ByteBuffer to search. |
c | the byte to search. |
start | the first byte. |
end | the last byte. |
public static int indexOf(final ByteBuffer buf, final int c, final int start, final int end)
//package com.java2s; //License from project: LGPL import java.nio.ByteBuffer; public class Main { /**//from w w w . ja va2 s. c om * Returns the index of the given char within the given {@link ByteBuffer}. * * @param buf the {@link ByteBuffer} to search. * @param c the byte to search. * @param start the first byte. * @param end the last byte. * @return the position, or -1 if not found. */ public static int indexOf(final ByteBuffer buf, final int c, final int start, final int end) { final int cc = c; // having a local copy is faster than the stack version final ByteBuffer bb = buf; int pos = start, rem = end - start; while (rem-- != 0) { if (bb.get(pos) == cc) return pos; ++pos; } return -1; } }