public class TransientFileFactory extends Object
TransientFileFactory
utility class can be used to create
transient files, i.e. temporary files that are automatically
removed once the associated File
object is reclaimed by the
garbage collector.
File deletion is handled by a low-priority background thread.
Modifier and Type | Method and Description |
---|---|
File |
createTransientFile(String prefix,
String suffix,
File directory)
Same as
File.createTempFile(String, String, File) except that
the newly-created file will be automatically deleted once the
returned File object has been gc'ed. |
static TransientFileFactory |
getInstance()
Returns the singleton
TransientFileFactory instance. |
static void |
shutdown()
Shuts this factory down removing all temp files and removes shutdown hook.
|
public static TransientFileFactory getInstance()
TransientFileFactory
instance.public File createTransientFile(String prefix, String suffix, File directory) throws IOException
File.createTempFile(String, String, File)
except that
the newly-created file will be automatically deleted once the
returned File
object has been gc'ed.prefix
- The prefix string to be used in generating the file's
name; must be at least three characters longsuffix
- The suffix string to be used in generating the file's
name; may be null
, in which case the
suffix ".tmp"
will be useddirectory
- The directory in which the file is to be created, or
null
if the default temporary-file
directory is to be usedIOException
- If a file could not be createdpublic static void shutdown()
Warning!!!
This should be called by a web-application IF it is unloaded AND IF jackrabbit-jcr-commons.jar had been loaded by the webapp classloader. This must be called after all repositories had been stopped, so use with great care!
See http://issues.apache.org/jira/browse/JCR-1636 for details.
Copyright © 2004–2024 The Apache Software Foundation. All rights reserved.