Class FileWatcher
java.lang.Object
org.simpleframework.common.buffer.FileWatcher
- All Implemented Interfaces:
FileFilter
The
FileWatcher
object is used to create files that
are to be used for file buffers. All files created by this are
created in the java.io.tmpdir
path. Temporary files
created in this directory last for a configurable length of time
before they are deleted.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFileWatcher
(String prefix) Constructor for theFileWatcher
object.FileWatcher
(String prefix, long duration) Constructor for theFileWatcher
object. -
Method Summary
Modifier and TypeMethodDescriptionboolean
This determines if the file provided is an acceptable file for deletion.private boolean
This determines if the file provided is an acceptable file for deletion.private void
When this method is invoked the files that match the pattern of the temporary files are evaluated for deletion.create()
This will create a temporary file which can be used as a buffer forFileBuffer
objects.private File
This will create a temporary file which can be used as a buffer forFileBuffer
objects.
-
Field Details
-
prefix
This is the prefix for the temporary files created. -
duration
private final long durationThis is the duration the files created will exist for.
-
-
Constructor Details
-
FileWatcher
Constructor for theFileWatcher
object. This will allow temporary files to exist for five minutes. After this time the will be removed from the underlying directory. Any request for a new file will result in a sweep of the temporary directory for all matching files, if they have expired they will be deleted.- Parameters:
prefix
- this is the file name prefix for the files
-
FileWatcher
Constructor for theFileWatcher
object. This will allow temporary files to exist for a configurable length of time. After this time the will be removed from the underlying directory. Any request for a new file will result in a sweep of the temporary directory for all matching files, if they have expired they will be deleted.- Parameters:
prefix
- this is the file name prefix for the filesduration
- this is the duration the files exist for
-
-
Method Details
-
create
This will create a temporary file which can be used as a buffer forFileBuffer
objects. The file returned by this method will be created before it is returned, which ensures it can be used as a means to buffer bytes. All files are created in thejava.io.tmpdir
location, which represents the underlying file system temporary file destination.- Returns:
- this returns a created temporary file for buffers
- Throws:
IOException
-
create
This will create a temporary file which can be used as a buffer forFileBuffer
objects. The file returned by this method will be created before it is returned, which ensures it can be used as a means to buffer bytes. All files are created in thejava.io.tmpdir
location, which represents the underlying file system temporary file destination.- Parameters:
prefix
- this is the prefix of the file to be created- Returns:
- this returns a created temporary file for buffers
- Throws:
IOException
-
clean
When this method is invoked the files that match the pattern of the temporary files are evaluated for deletion. Only those files that have not been modified in the duration period can be deleted. This ensures the file system is not exhausted.- Parameters:
path
- this is the path of the file to be evaluated- Throws:
IOException
-
accept
This determines if the file provided is an acceptable file for deletion. Acceptable files are those that match the pattern of files created by this file system object. If the file is a matching file then it is a candidate for deletion.- Specified by:
accept
in interfaceFileFilter
- Parameters:
file
- this is the file to evaluate for deletion- Returns:
- this returns true if the file matches the pattern
-
accept
This determines if the file provided is an acceptable file for deletion. Acceptable files are those that match the pattern of files created by this file system object. If the file is a matching file then it is a candidate for deletion.- Parameters:
file
- this is the file to evaluate for deletionname
- this is the name of the file to be evaluated- Returns:
- this returns true if the file matches the pattern
-