spring-framework / org.springframework.util / FileSystemUtils

FileSystemUtils

abstract class FileSystemUtils

Utility methods for working with the file system.

Author
Rob Harrop

Author
Juergen Hoeller

Since
2.5.3

See Also
java.io.Filejava.nio.file.Pathjava.nio.file.Files

Constructors

<init>

FileSystemUtils()

Utility methods for working with the file system.

Functions

copyRecursively

open static fun copyRecursively(src: File, dest: File): Unit
open static fun copyRecursively(src: Path, dest: Path): Unit

Recursively copy the contents of the src file/directory to the dest file/directory.

deleteRecursively

open static fun deleteRecursively(root: File): Boolean

Delete the supplied File - for directories, recursively delete any nested directories or files as well.

Note: Like File#delete(), this method does not throw any exception but rather silently returns false in case of I/O errors. Consider using #deleteRecursively(Path) for NIO-style handling of I/O errors, clearly differentiating between non-existence and failure to delete an existing file.

open static fun deleteRecursively(root: Path): Boolean

Delete the supplied File - for directories, recursively delete any nested directories or files as well.