deleteIfExists

JVM
JRE7
1.4
@ExperimentalPathApi fun Path.deleteIfExists(): Boolean

Deletes the file or empty directory specified by this path if it exists.

Exceptions

DirectoryNotEmptyException - if the directory exists but is not empty

Return true if the existing file was successfully deleted, false if the file does not exist.

See Also

Files.deleteIfExists