ByteString
Wraps given bytes into a byte string.
Parameters
bytes
a sequence of bytes to be wrapped.
Samples
import kotlinx.io.bytestring.*
import kotlin.test.*
fun main() {
//sampleStart
val emptyByteString = ByteString()
assertTrue(emptyByteString.isEmpty())
assertEquals(0, emptyByteString.size)
val byteStringFromBytes = ByteString(1, 2, 3)
assertFalse(byteStringFromBytes.isEmpty())
assertEquals(3, byteStringFromBytes.size)
//sampleEnd
}
Wraps given bytes into a byte string.
Internally, bytes will be stored as ByteArray, and accesses to individual ByteString's bytes will return a signed Byte as if someone call bytes[i].toByte()
.
Parameters
bytes
a sequence of bytes to be wrapped.
Samples
import kotlinx.io.bytestring.*
import kotlin.test.*
fun main() {
//sampleStart
val byteStringFromBytes = ByteString(0xCAu, 0xFEu)
assertFalse(byteStringFromBytes.isEmpty())
assertEquals(2, byteStringFromBytes.size)
//sampleEnd
}