|
||||||||||
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(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. |
|
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(Class<T> klass)
Returns the latest of the tracked resources that implements or extends the given interface or class. |
|
void |
setTemporaryFileDirectory(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(File tmp)
createTemporaryFile()
method.
tmp
- temporary file directory,
or null
for the system defaultpublic File createTemporaryFile() throws IOException
close()
method is called.
IOException
public void addResource(Closeable resource)
close()
method is called.
resource
- resource to be trackedpublic <T extends Closeable> T getResource(Class<T> klass)
klass
- interface or class
null
if not foundpublic void close() throws IOException
Any thrown exceptions from managed resources are collected and then re-thrown only once all the resources have been closed.
close
in interface Closeable
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 |