endsWith

Returns true if this byte string ends with the suffix specified by the byteArray.

Behavior of this method is compatible with CharSequence.endsWith.

Parameters

byteArray

the suffix to check for.

Samples

import kotlinx.io.bytestring.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val string = ByteString(1, 2, 3, 4, 5)

assertTrue(string.endsWith(byteArrayOf(1, 2, 3, 4, 5)))
assertTrue(string.endsWith(byteArrayOf(/* empty byte array */)))
assertTrue(string.endsWith(byteArrayOf(3, 4, 5)))
assertFalse(string.endsWith(byteArrayOf(2, 4, 5)))
assertFalse(string.endsWith(byteArrayOf(0, 1, 2, 3, 4, 5))) 
   //sampleEnd
}

Returns true if this byte string ends with the suffix specified by the byteString.

Behavior of this method is compatible with CharSequence.endsWith.

Parameters

byteString

the suffix to check for.

Samples

import kotlinx.io.bytestring.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val string = ByteString(1, 2, 3, 4, 5)

assertTrue(string.endsWith(string))
assertTrue(string.endsWith(ByteString(/* empty byte string */)))
assertTrue(string.endsWith(ByteString(3, 4, 5)))
assertFalse(string.endsWith(ByteString(2, 4, 5)))
assertFalse(string.endsWith(ByteString(0, 1, 2, 3, 4, 5))) 
   //sampleEnd
}