readBytes

Gets the entire content of this file as a byte array.

fun File.readBytes(): ByteArray(source)
import java.io.File

fun main() {
    val file = File("example.txt")
    val bytes = file.readBytes()
    println("Read ${bytes.size} bytes")
}

Source