tuweni / 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 - Path!: The target file to be replaced (if it exists).

bytes - ByteArray!: 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 - Path!: The target file to be replaced (if it exists).

fn - IOConsumer<Writer!>!: 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 - Path!: The target file to be replaced (if it exists).

charset - Charset!: The charset of the file.

fn - IOConsumer<Writer!>!: A consumer that will be provided a buffered Writer instance that will write to the file.

Exceptions

IOException - If an I/O error occurs.