write

abstract fun write(file: Path, mustCreate: Boolean = false, writerAction: BufferedSink.() -> Unit)(source)

Creates a sink to write file, executes writerAction to write it, and then closes the sink. This is a compact way to write a file.

Parameters

mustCreate

true to throw an IOException instead of overwriting an existing file. This is equivalent to O_EXCL on POSIX and CREATE_NEW on Windows.