Hello! Just a quick question: if I want to use a K...
# getting-started
c
Hello! Just a quick question: if I want to use a Kotlin File() with a PrintWriter, should I close it afterwards? The dev guide doesn't bother to do so (https://developer.android.com/training/data-storage/files). Here is what I have:
Copy code
fun writeToLog(s: String) {
        val logFile = File(c.filesDir, FILENAME)
        logFile.printWriter().use {
            it.print(s)
            it.close()
        }
    }
Is the close() unnecessary?
🚫 1