Package org.h2.util

# Class TempFileDeleter

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

public class TempFileDeleter extends Object
This class deletes temporary files when they are not used any longer.

## Method Summary

Modifier and Type
Method
Description
`Reference<?>`
`addFile(Object resource, 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(Reference<?> ref, Object resource)`
Delete the given file or close the closeable now.
`void`
`deleteUnused()`
Delete all unused resources now.
`static TempFileDeleter`
`getInstance()`
`void`
`stopAutoDelete(Reference<?> ref, 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 Details

### getInstance

public static TempFileDeleter getInstance()

### addFile

public Reference<?> addFile(Object resource, 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(Reference<?> ref, 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(Reference<?> ref, 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