How to convert byte array to String [Kotlin]

In order to convert a byte array to String, you can make use of the String construction that takes in a byte array as an input argument,

Example:
fun main() {
    val byteArray = byteArrayOf(80,81,83,84,85,86)
    val myStr = String(byteArray)
    println(myStr) 
}
Output:

PQRSTUV



Have Questions? Post them here!

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!