index Of
Equivalent to indexOf(b, 0).
Returns the index of the first b
in the buffer at or after fromIndex
. This expands the buffer as necessary until b
is found. This reads an unbounded number of bytes into the buffer. Returns -1 if the stream is exhausted before the requested byte is found.
Buffer buffer = new Buffer();
buffer.writeUtf8("Don't move! He can't see us if we don't move.");
byte m = 'm';
assertEquals(6, buffer.indexOf(m));
assertEquals(40, buffer.indexOf(m, 12));
Returns the index of b
if it is found in the range of fromIndex
inclusive to toIndex
exclusive. If b
isn't found, or if fromIndex == toIndex
, then -1 is returned.
The scan terminates at either toIndex
or the end of the buffer, whichever comes first. The maximum number of bytes scanned is toIndex-fromIndex
.
Equivalent to indexOf(bytes, 0).
Returns the index of the first match for bytes
in the buffer at or after fromIndex
. This expands the buffer as necessary until bytes
is found. This reads an unbounded number of bytes into the buffer. Returns -1 if the stream is exhausted before the requested bytes are found.
ByteString MOVE = ByteString.encodeUtf8("move");
Buffer buffer = new Buffer();
buffer.writeUtf8("Don't move! He can't see us if we don't move.");
assertEquals(6, buffer.indexOf(MOVE));
assertEquals(40, buffer.indexOf(MOVE, 12));