Convert String To ByteArray And ByteArray to String (Kotlin)

April 13, 2018
val input = "This is a string"

// String to ByteArray
val byteArray = input.toByteArray(Charsets.UTF_8)

// ByteArray to String
val output = String(byteArray, Charsets.UTF_8)
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.