public class FileCleaner extends Object implements IFileCleaner
IFileCleaner
that uses Apache commons-io
FileCleaningTracker
to track and clean the temporary created files.
Note: this implementation starts a daemon thread to do the actual work, so it may not be used in some environments like Google AppEngine.
Constructor and Description |
---|
FileCleaner()
Construct.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Call this method to stop the cleaner and to free all allocated resources by it
|
void |
track(File file,
Object marker)
Track the specified file, using the provided marker, deleting the file when the marker
instance is garbage collected.
|
void |
track(File file,
Object marker,
org.apache.commons.io.FileDeleteStrategy deleteStrategy)
Track the specified file, using the provided marker, deleting the file when the marker
instance is garbage collected.
|
public void track(File file, Object marker)
IFileCleaner
track
in interface IFileCleaner
file
- the file to be tracked, not nullmarker
- the marker object used to track the file, not nullpublic void track(File file, Object marker, org.apache.commons.io.FileDeleteStrategy deleteStrategy)
IFileCleaner
track
in interface IFileCleaner
file
- the file to be tracked, not nullmarker
- the marker object used to track the file, not nulldeleteStrategy
- the strategy that actually deletes the file. E.g. to delete a non-empty folder the
strategy should delete all children firstpublic void destroy()
IFileCleaner
destroy
in interface IFileCleaner
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.