public class FileDeleteStrategy
extends java.lang.Object
There is more than one way to delete a file. You may want to limit access to certain directories, to only delete directories if they are empty, or maybe to force deletion.
This class captures the strategy to use and is designed for user subclassing.
Modifier and Type | Field and Description |
---|---|
static FileDeleteStrategy |
FORCE
The singleton instance for forced file deletion, which always deletes,
even if the file represents a non-empty directory.
|
static FileDeleteStrategy |
NORMAL
The singleton instance for normal file deletion, which does not permit
the deletion of directories that are not empty.
|
Modifier and Type | Method and Description |
---|---|
void |
delete(java.io.File fileToDelete)
Deletes the file object, which may be a file or a directory.
|
boolean |
deleteQuietly(java.io.File fileToDelete)
Deletes the file object, which may be a file or a directory.
|
java.lang.String |
toString()
Gets a string describing the delete strategy.
|
public static final FileDeleteStrategy NORMAL
public static final FileDeleteStrategy FORCE
public boolean deleteQuietly(java.io.File fileToDelete)
IOException
s are caught and false returned instead.
If the file does not exist or is null, true is returned.
Subclass writers should override doDelete(File)
, not this method.
fileToDelete
- the file to delete, null returns truepublic void delete(java.io.File fileToDelete) throws java.io.IOException
Subclass writers should override doDelete(File)
, not this method.
fileToDelete
- the file to delete, not nulljava.lang.NullPointerException
- if the file is nulljava.io.IOException
- if an error occurs during file deletionpublic java.lang.String toString()
toString
in class java.lang.Object
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"