How to write to file in Kotlin

This tutorial shows you how to write to File in Kotlin using PrintWriter, BufferedWriter or just File Kotlin extension functions.

>>> Refer to:

I. Technology

– Java 1.8
– Kotlin 1.1.2

II. Practice

1. PrintWriter

Check Result:

2. BufferedWriter

Check Result:

3. File Kotlin extension functions

Check Result:

4. When input text is null

Add Comment