Package org.alfresco.util
Class Deleter
java.lang.Object
org.alfresco.util.Deleter
Utility to delete a file or directory recursively.
- Author:
- britt
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Delete by File.static void
Delete by path.static void
deleteEmptyParents
(File file, File rootDir) Same behaviour as fordeleteEmptyParents(File, String)
but with therootDir
parameter specified as aFile
object.static void
deleteEmptyParents
(File file, String rootDir) Recursively deletes the parents of the specified file stopping whenrootDir
is reached.
-
Constructor Details
-
Deleter
public Deleter()
-
-
Method Details
-
Delete
Delete by path.- Parameters:
path
-
-
Delete
Delete by File.- Parameters:
toDelete
-
-
deleteEmptyParents
Recursively deletes the parents of the specified file stopping whenrootDir
is reached. The file itself must have been deleted before calling this method - since only empty directories can be deleted.For example:
deleteEmptyParents(new File("/tmp/a/b/c/d.txt"), "/tmp/a")
Will delete directories c and b assuming that they are both empty. It will leave /tmp/a even if it is empty as this is the
rootDir
- Parameters:
file
- The path of the file whose parent directories should be deleted.rootDir
- Top level directory where deletion should stop. Must be the canonical path to ensure correct comparisons.
-
deleteEmptyParents
Same behaviour as fordeleteEmptyParents(File, String)
but with therootDir
parameter specified as aFile
object.- Parameters:
file
-rootDir
-- See Also:
-