rangeEquals

common
abstract fun rangeEquals(offset: Long, bytes: ByteString): Boolean

Returns true if the bytes at offset in this source equal bytes. This expands the buffer as necessary until a byte does not match, all bytes are matched, or if the stream is exhausted before enough bytes could determine a match.

ByteString simonSays = ByteString.encodeUtf8("Simon says:");

Buffer standOnOneLeg = new Buffer().writeUtf8("Simon says: Stand on one leg.");
assertTrue(standOnOneLeg.rangeEquals(0, simonSays));

Buffer payMeMoney = new Buffer().writeUtf8("Pay me $1,000,000.");
assertFalse(payMeMoney.rangeEquals(0, simonSays));
abstract fun rangeEquals(offset: Long, bytes: ByteString): Boolean
abstract fun rangeEquals(offset: Long, bytes: ByteString, bytesOffset: Int, byteCount: Int): Boolean
common
abstract fun rangeEquals(offset: Long, bytes: ByteString, bytesOffset: Int, byteCount: Int): Boolean

Returns true if byteCount bytes at offset in this source equal bytes at bytesOffset. This expands the buffer as necessary until a byte does not match, all bytes are matched, or if the stream is exhausted before enough bytes could determine a match.