Home > Contents > Index >
Expanded TOC | Accordion TOC | Annotated TOC | Index
Utilities.empty
Deletes the contents of a folder.
This method has two variants:
- emptyFolder (Variant 1) recursively deletes the contents within a folder, and then, optionally, the folder itself.
- emptyFolder (Variant 2) recursively deletes all files that match the chosen pattern from the specified directory tree.
Utilities.empty
Recursively deletes the contents within a folder, and then, optionally, the folder itself.
Syntax
public static final int emptyFolder(String path, boolean bDelete)Parameters
path
- The pathname of the directory whose contents are to be deleted.
bDelete
- Specify
true
to delete the folder itself. Specifyfalse
to suppress deleting the folder itself.
Returns
Returns zero (0) on success, or error code on error.
Example
The following code empties the contents of the
/tmp
directory and any of its subdirectories but does not delete the/tmp
itself:if ( Utilities.emptyFolder( "/tmp", false ) ) { // the tmp folder is now empty }
Utilities.empty
Recursively deletes all files which match the chosen pattern from the specified directory tree.
Syntax
public static final int emptyFolder(String path, String pattern)Parameters
path
- The pathname of the directory whose contents are to be deleted.
pattern
- The pattern you want to find and delete.
Returns
Returns zero (0) on success, or error code on error.
Home > Contents > Index > ![]()
Oracle JAVA Reference
Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.