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!

Topics Coverage:


🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.

Follow Us: GitHub | Facebook | Twitter | Instagram