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!


















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap