Kotlin read file with File.readText

File.readText() gets the entire content of this file as a String. It is not recommended to use this method on huge files.

Kotlin read a file with File.readText

In the example, we read the whole file into a string and print it to the console.
import java.io.File

fun main(args: Array<String>) {
    val fileName = "src/resources/sample.txt"

    val content = File(fileName).readText()