As the result of executing the preceding code, a new temp_file file is going to be created under the src/main/resources directory. Keep in mind that in case the temp_file already exists it is going to be overridden. Next, with the help of the writeText() function its contents are going to be printed to the console:
"No one in the brief history of computing has ever written a piece of perfect software. It's unlikely that you'll be the first." - Andy Hunt
The writeText() function wraps the java.io.FileOutputStream API, providing a neat way of writing content to the file. Under the hood, it accesses FileOutputStream inside the use() function, so you can be sure that it autocloses any streams that are opened during the write operation.
You can also pass the additional charset: Charset argument to writeText(), which by default is equal to the Charsets.UTF_8 value. If you'd like to use another charset, you can specify it by passing a proper one as the charset argument. You can find the available charset types inside the kotlin.text.Charsets object. You can also find them listed in the official documentation at https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-charsets.