toString

JVM
1.0
fun ByteArray.toString(charset: Charset): String
(source)

Converts the contents of this byte array to a string using the specified charset.

import java.util.Locale
import kotlin.test.*

fun main(args: Array<String>) {
//sampleStart
val charset = Charsets.UTF_8
val byteArray = "Hello".toByteArray(charset)
println(byteArray.contentToString()) // [72, 101, 108, 108, 111]
println(byteArray.toString(charset)) // Hello
//sampleEnd
}