Create And Delete Files And Directories
Demonstrate how to create files or directories from a path object
Delete
Delete files and directories
import scalax.file.Path
val path: Path = Path ("/tmp/file")
// Will throw IOException if file could not be deleted
// even if it cannot be deleted because it does not exist
path.delete()
// Will not throw exception if file does not exist but will
// if it is a non-empty directory or not writeable
path.deleteIfExists()
// Delete path and all children. This is currently not a safe method so
// it should be used with caution. Future versions will be better
// by default it will throw an exception if one of the files cannot be deleted
path.deleteRecursively()
// Delete path and all children. If a file cannot be deleted then continue on and delete
// all that can be deleted
path.deleteRecursively(true)
// or
path.deleteRecursively(continueOnFailure=true)