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

Files

class Files (source)

Utility methods for working with files.

Functions

atomicReplace

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

Write a temporary file and then replace target.

copyResource

static fun copyResource(resourceName: String, destination: Path, vararg options: OpenOption): Path
static fun copyResource(classloader: ClassLoader, resourceName: String, destination: Path, vararg options: OpenOption): Path

Copies the content of a resource to a file.

static fun copyResource(resourceName: String, out: OutputStream): Long
static fun copyResource(classloader: ClassLoader, resourceName: String, out: OutputStream): Long

Copies the content of a resource to an output stream.

createFileIfMissing

static fun createFileIfMissing(path: Path, vararg attrs: FileAttribute<*>): Boolean

Create a file, if it does not already exist.

deleteRecursively

static fun deleteRecursively(directory: Path): Unit

Delete a directory and all files contained within it.