In Java, when you write code in try(...), if exception throw, the resource will be closed automactially:
This is not necessary in Kotlin
fun printFile() { val input = FileInputStream("file.txt") input.use { // an exception can be thrown here // and input resource will be closed automaticlly } }