In Kotlin you can do the same with a function called toByteArray
. Default values are provided for charset, and Charsets.UTF_8
is used if not specified in the argument.
val foo = "foo"
foo.toByteArray()
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/to-byte-array.html
Recommended Posts