|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.util.IOUtils
public final class IOUtils
Method Summary | ||
---|---|---|
static void |
closeSafely(Closeable... objects)
Closes all given Closeables, suppressing all thrown exceptions. |
|
static
|
closeSafely(E priorException,
Closeable... objects)
Closes all given Closeables, suppressing all thrown exceptions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <E extends Exception> void closeSafely(E priorException, Closeable... objects) throws E extends Exception, IOException
Closes all given Closeables, suppressing all thrown exceptions. Some of the Closeables may be null, they are ignored. After everything is closed, method either throws priorException, if one is supplied, or the first of suppressed exceptions, or completes normally.
Sample usage:
Closeable resource1 = null, resource2 = null, resource3 = null; ExpectedException priorE = null; try { resource1 = ...; resource2 = ...; resource3 = ...; // Acquisition may throw ExpectedException ..do..stuff.. // May throw ExpectedException } catch (ExpectedException e) { priorE = e; } finally { closeSafely(priorE, resource1, resource2, resource3); }
priorException
- null or an exception that will be rethrown after method completionobjects
- objects to call close() on
E extends Exception
IOException
public static void closeSafely(Closeable... objects) throws IOException
Closes all given Closeables, suppressing all thrown exceptions. Some of the Closeables may be null, they are ignored. After everything is closed, method either throws the first of suppressed exceptions, or completes normally.
objects
- objects to call close() on
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |