Ben Chuanlong Du's Blog

It is never too late to learn.

Kotlin IO

In [ ]:
File("/path/to/some/file")
In [ ]:
One-time write. 
Notice that it will overwrite the previous content of the file.
In [ ]:
File("/path/to/some/file").writeText("string to write to file")
In [ ]:
File("/path/to/some/file").writer

The BufferedWriter is prefered most of the time.

In [ ]:
File("/path/to/some/file").bufferedWriter

Comments