Is there a way to open and close a stream easily at kotlin?
Answer #1 100 %Closeable.use
is what you're looking for:
val result = FileInputStream("/home/user/123.txt").use { input ->
//Transform input to X
}
Closeable.use
is what you're looking for:
val result = FileInputStream("/home/user/123.txt").use { input ->
//Transform input to X
}