readBytes

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

inline fun Path.readBytes(): ByteArray(source)
import java.nio.file.Paths

fun main() {
    val path = Paths.get("example.txt")
    val bytes = path.readBytes()
    println(String(bytes))
}

Source