inputStream

Constructs a new FileInputStream of this file and returns it as a result.

inline fun File.inputStream(): FileInputStream(source)
import java.io.File

fun main() {
    val file = File("example.txt")
    // Open a FileInputStream using the inline extension function
    file.inputStream().use { input ->
        val bytes = input.readBytes()
        println("Read ${bytes.size} bytes from ${file.name}")
    }
}

Source