index Of Element
Equivalent to indexOfElement(targetBytes, 0).
abstract fun indexOfElement(targetBytes: ByteString, fromIndex: Long): Long
Content copied to clipboard
abstract fun indexOfElement(targetBytes: ByteString, fromIndex: Long): Long
Content copied to clipboard
Returns the first index in this buffer that is at or after fromIndex
and that contains any of the bytes in targetBytes
. This expands the buffer as necessary until a target byte 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.
ByteString ANY_VOWEL = ByteString.encodeUtf8("AEOIUaeoiu");
Buffer buffer = new Buffer();
buffer.writeUtf8("Dr. Alan Grant");
assertEquals(4, buffer.indexOfElement(ANY_VOWEL)); // 'A' in 'Alan'.
assertEquals(11, buffer.indexOfElement(ANY_VOWEL, 9)); // 'a' in 'Grant'.