public class CleanupHook
extends java.lang.Object
implements java.lang.Runnable
CleanupHook
class may be used by programs to clean
up resources after the Java VM has exited. The hook has only one
instance, retrieved using the getInstance()
method, and
registers itself to be run using the Runtime.addShutdownHook(java.lang.Thread)
method. Currently, the only
cleanup task is file deletion.Modifier and Type | Method and Description |
---|---|
void |
cancelDelete(java.io.File file)
Removes a file from the set of files to delete upon cleanup.
|
void |
cancelDelete(java.lang.String fileName)
Removes a file from the set of files to delete upon cleanup.
|
static CleanupHook |
getInstance()
Gets the one and only instance of this class.
|
void |
run()
Performs the cleanup.
|
void |
scheduleDelete(java.io.File file)
Adds a file to the set of files to delete upon cleanup.
|
void |
scheduleDelete(java.lang.String fileName)
Adds a file to the set of files to delete upon cleanup.
|
public static CleanupHook getInstance()
public void scheduleDelete(java.lang.String fileName)
fileName
- the file name to add.public void scheduleDelete(java.io.File file)
file
- the file to add.public void cancelDelete(java.lang.String fileName)
fileName
- the file name to remove.public void cancelDelete(java.io.File file)
file
- the file to remove.public void run()
run
in interface java.lang.Runnable