fromByteArray

Common
JVM
JS
Native
1.0
fun fromByteArray(byteArray: ByteArray): Uuid
(source)

Creates a uuid from a byte array containing 128 bits split into 16 bytes.

Each byte in the byteArray sequentially represents the next 8 bits of the uuid, starting from the most significant 8 bits in the first byte to the least significant 8 bits in the last byte.

import kotlin.uuid.*

fun main(args: Array<String>) {
//sampleStart
val byteArray = byteArrayOf(
    0x55, 0x0e, 0x84.toByte(), 0x00, 0xe2.toByte(), 0x9b.toByte(), 0x41, 0xd4.toByte(),
    0xa7.toByte(), 0x16, 0x44, 0x66, 0x55, 0x44, 0x00, 0x00
)
val uuid = Uuid.fromByteArray(byteArray)
println(uuid) // 550e8400-e29b-41d4-a716-446655440000
//sampleEnd
}

Parameters

byteArray - A 16-byte array containing the uuid bits.

Exceptions

IllegalArgumentException - If the size of the byteArray is not exactly 16.

Return A new uuid based on the specified bits.

See Also

Uuid.toByteArray