|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tika.io.TemporaryResources
public class TemporaryResources
Utility class for tracking and ultimately closing or otherwise disposing a collection of temporary resources.
Note that this class is not thread-safe.
Constructor Summary | |
---|---|
TemporaryResources()
|
Method Summary | ||
---|---|---|
void |
addResource(java.io.Closeable resource)
Adds a new resource to the set of tracked resources that will all be closed when the close() method is called. |
|
void |
close()
Closes all tracked resources. |
|
java.io.File |
createTemporaryFile()
Creates and returns a temporary file that will automatically be deleted when the close() method is called. |
|
void |
dispose()
Calls the close() method and wraps the potential
IOException into a TikaException for convenience
when used within Tika. |
|
|
getResource(java.lang.Class<T> klass)
Returns the latest of the tracked resources that implements or extends the given interface or class. |
|
void |
setTemporaryFileDirectory(java.io.File tmp)
Sets the directory to be used for the temporary files created by the createTemporaryFile() method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TemporaryResources()
Method Detail |
---|
public void setTemporaryFileDirectory(java.io.File tmp)
createTemporaryFile()
method.
tmp
- temporary file directory,
or null
for the system defaultpublic java.io.File createTemporaryFile() throws java.io.IOException
close()
method is called.
java.io.IOException
public void addResource(java.io.Closeable resource)
close()
method is called.
resource
- resource to be trackedpublic <T extends java.io.Closeable> T getResource(java.lang.Class<T> klass)
klass
- interface or class
null
if not foundpublic void close() throws java.io.IOException
Any thrown exceptions from managed resources are collected and then re-thrown only once all the resources have been closed.
close
in interface java.io.Closeable
java.io.IOException
- if one or more of the tracked resources
could not be closedpublic void dispose() throws TikaException
close()
method and wraps the potential
IOException
into a TikaException
for convenience
when used within Tika.
TikaException
- if one or more of the tracked resources
could not be closed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |