write

fun write(outFile: File, writeContent: (File) -> Unit)

Writes to outFile by invoking writeContent against a temporary sibling file and atomically moving the result into place. Missing parent directories are created.

Parameters

outFile

target file; must have a parent directory

writeContent

callback that writes the content to the provided temporary file

Throws

if outFile has no parent directory

if writing or moving fails