Package noaa.coastwatch.tools
Class CleanupHook
java.lang.Object
noaa.coastwatch.tools.CleanupHook
- All Implemented Interfaces:
Runnable
The
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.- Since:
- 3.1.9
- Author:
- Peter Hollemans
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancelDelete
(File file) Removes a file from the set of files to delete upon cleanup.void
cancelDelete
(String fileName) Removes a file from the set of files to delete upon cleanup.static CleanupHook
Gets the one and only instance of this class.void
run()
Performs the cleanup.void
scheduleDelete
(File file) Adds a file to the set of files to delete upon cleanup.void
scheduleDelete
(String fileName) Adds a file to the set of files to delete upon cleanup.
-
Method Details
-
getInstance
Gets the one and only instance of this class. -
scheduleDelete
Adds a file to the set of files to delete upon cleanup. If the file was already scheduled for deletion, no action is performed.- Parameters:
fileName
- the file name to add.
-
scheduleDelete
Adds a file to the set of files to delete upon cleanup. If the file was already scheduled for deletion, no action is performed.- Parameters:
file
- the file to add.
-
cancelDelete
Removes a file from the set of files to delete upon cleanup. If the file was never scheduled for deletion, no action is performed.- Parameters:
fileName
- the file name to remove.
-
cancelDelete
Removes a file from the set of files to delete upon cleanup. If the file was never scheduled for deletion, no action is performed.- Parameters:
file
- the file to remove.
-
run
public void run()Performs the cleanup. This method is normally only called in response to a system shutdown.
-