Read a Text asset(text file from assets folder) as a String in Kotlin (Android)

I found this in a youtube video. Here is the link https://www.youtube.com/watch?v=o5pDghyRHmI

val file_name = "qjsonfile.json"
val json_string = application.assets.open(file_name).bufferedReader().use{
            it.readText()
        }

Saves the JSON or text to the string json_string.


When in doubt close the stream yourself!

application.assets.open(file_name).apply {
                json_string = this.readBytes().toString(Charsets.UTF_8)
            }.close()