Try-with-resources in Kotlin
There is a use function in kotlin-stdlib (src). How to use it: OutputStreamWriter(r.getOutputStream()).use { // `it` is your OutputStreamWriter it.write(‘a’) }
There is a use function in kotlin-stdlib (src). How to use it: OutputStreamWriter(r.getOutputStream()).use { // `it` is your OutputStreamWriter it.write(‘a’) }
Here’s my take on the alternatives: 1) try (BufferedWriter bw = new BufferedWriter(new FileWriter(file))) { bw.write(text); } For me, the best thing coming to Java from traditional C++ 15 years ago was that you could trust your program. Even if things are in the muck and going wrong, which they often do, I want the … Read more