Deletes all files within the directory at the given
path
#deleteRecursively. Does not delete the directory itself. Deletes symbolic links, not their targets
(subject to the caveat below). If
path itself is a symbolic link to a directory, that
link is followed and the contents of the directory it targets are deleted.
If an I/O exception occurs attempting to read, open or delete any file under the given
directory, this method skips that file and continues. All such exceptions are collected and,
after attempting to delete all files, an
IOException is thrown containing those
exceptions as
Throwable#getSuppressed().
Warning: Security of recursive deletes
On a file system that supports symbolic links and does not support
SecureDirectoryStream, it is possible for a recursive delete to delete files and directories
that are outside the directory being deleted. This can happen if, after checking that a
file is a directory (and not a symbolic link), that directory is replaced by a symbolic link to
an outside directory before the call that opens the directory to read its entries.
By default, this method throws
InsecureRecursiveDeleteException if it can't
guarantee the security of recursive deletes. If you wish to allow the recursive deletes anyway,
pass
RecursiveDeleteOption#ALLOW_INSECURE to this method to override that behavior.