io / org.apache.tuweni.io.file / Files / atomicReplace

atomicReplace

static fun atomicReplace(path: Path, bytes: ByteArray): Unit (source)

Write a temporary file and then replace target.

Parameters

path - The target file to be replaced (if it exists).

bytes - The bytes to be written.

Exceptions

IOException - If an I/O error occurs.

static fun atomicReplace(path: Path, fn: IOConsumer<Writer>): Unit (source)

Write a temporary file and then replace target.

Parameters

path - The target file to be replaced (if it exists).

fn - A consumer that will be provided a buffered Writer instance that will write to the file.

Exceptions

IOException - If an I/O error occurs.

static fun atomicReplace(path: Path, charset: Charset, fn: IOConsumer<Writer>): Unit (source)

Write a temporary file and then replace target.

Parameters

path - The target file to be replaced (if it exists).

charset - The charset of the file.

fn - A consumer that will be provided a buffered Writer instance that will write to the file.

Exceptions

IOException - If an I/O error occurs.