org.h2.util

## Class TempFileDeleter

- java.lang.Object
- - org.h2.util.TempFileDeleter

    public class TempFileDeleter
    extends java.lang.Object

This class deletes temporary files when they are not used any longer.

### Method Summary

Methods
`java.lang.ref.Reference<?>` `addFile(java.lang.Object resource, java.lang.Object monitor)` Add a file or a closeable to the list of temporary objects to delete.
`void` `deleteAll()` Delete all registered temp resources.
`void` `deleteFile(java.lang.ref.Reference<?> ref, java.lang.Object resource)` Delete the given file or close the closeable now.
`void` `deleteUnused()` Delete all unused resources now.
`static TempFileDeleter` `getInstance()`
`void` `stopAutoDelete(java.lang.ref.Reference<?> ref, java.lang.Object resource)` This method is called if a file should no longer be deleted or a resource should no longer be closed if the object is garbage collected.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### getInstance

    public static TempFileDeleter getInstance()

#### addFile

    public java.lang.ref.Reference<?> addFile(java.lang.Object resource,
                                     java.lang.Object monitor)

Add a file or a closeable to the list of temporary objects to delete. The file is deleted once the file object is garbage collected.

Parameters:
  `resource` - the file name or the closeable
  `monitor` - the object to monitor
Returns:
  the reference that can be used to stop deleting the file or closing the closeable

#### deleteFile

    public void deleteFile(java.lang.ref.Reference<?> ref,
                  java.lang.Object resource)

Delete the given file or close the closeable now. This will remove the reference from the list.

Parameters:
  `ref` - the reference as returned by addFile
  `resource` - the file name or closeable

#### deleteAll

    public void deleteAll()

Delete all registered temp resources.

#### deleteUnused

    public void deleteUnused()

Delete all unused resources now.

#### stopAutoDelete

    public void stopAutoDelete(java.lang.ref.Reference<?> ref,
                      java.lang.Object resource)

This method is called if a file should no longer be deleted or a resource should no longer be closed if the object is garbage collected.

Parameters:
  `ref` - the reference as returned by addFile
  `resource` - file name or closeable