Home > Contents > 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
trueto delete the folder itself. Specifyfalseto 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
/tmpdirectory and any of its subdirectories but does not delete the/tmpitself: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, 2019, Oracle and/or its affiliates. All rights reserved.