public final class Closeables
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static void |
close(java.io.Closeable... closeables)
Closes the given array of closeables and returns a MultiIOException
of the thrown exceptions.
|
static void |
close(java.io.Closeable c,
boolean silently)
Closes the given closeable silently or wrapped as
RuntimeException depending on the parameter.
|
static void |
close(java.lang.Iterable<? extends java.io.Closeable> closeables)
Closes the given sequence of closeables and returns a MultiIOException
of the thrown exceptions.
|
static void |
close(java.lang.Object o)
If the target object implements Closeable, this method calls
it, otherwise its a no-op.
|
static void |
close(java.lang.Object c,
boolean silently)
Closes the given potentially closeable instance silently or wrapped as
RuntimeException depending on the parameter.
|
static void |
closeSilently(java.io.Closeable c)
Invoke the
close() method on the closeable instance
and throw away any IOException it might raise. |
static void |
closeSilently(java.lang.Object o)
Closes the given object if it implements the Closeable interface.
|
static void |
closeUnchecked(java.io.Closeable c)
Closes the given closeable instance and
wraps the IOException into a RuntimeException.
|
static void |
closeUnchecked(java.lang.Object c)
Closes the given object if it implements the Closeable interface and
wraps the IOException into a RuntimeException.
|
static java.io.Closeable |
emptyCloseable()
Returns an empty closeable object which does nothing.
|
static java.io.Closeable |
newCloseable(java.io.Closeable c0,
java.io.Closeable c1,
java.io.Closeable... closeables)
Wraps two or more closeables into one closeable.
|
static java.io.Closeable |
newCloseable(java.lang.Iterable<? extends java.io.Closeable> closeables)
Creates a composite closeable from the array of closeables.
|
static java.io.Closeable |
toCloseable(Action0 action)
Wraps the given action into a Closeable.
|
static java.io.Closeable |
toCloseable(Action0E<? extends java.io.IOException> action)
Wraps the given action into a Closeable.
|
@Nonnull public static java.io.Closeable emptyCloseable()
@Nonnull
public static java.io.Closeable newCloseable(@Nonnull
java.io.Closeable c0,
@Nonnull
java.io.Closeable c1,
@Nonnull
java.io.Closeable... closeables)
IOExceptions thrown from the closeables are suppressed.c0 - the first closeablec1 - the second closeablecloseables - the rest of the closeablespublic static void closeSilently(java.io.Closeable c)
close() method on the closeable instance
and throw away any IOException it might raise.c - the closeable instance, nulls are simply ignoredpublic static void closeUnchecked(@Nullable
java.io.Closeable c)
c - the closeable instance, null means no-oppublic static void close(@Nullable
java.io.Closeable c,
boolean silently)
c - the closeablesilently - close silently?public static void close(@Nullable
java.lang.Object c,
boolean silently)
c - the closeablesilently - close silently?public static void closeUnchecked(@Nullable
java.lang.Object c)
c - the closeable instance, null means no-op@Nonnull
public static java.io.Closeable newCloseable(@Nonnull
java.lang.Iterable<? extends java.io.Closeable> closeables)
IOExceptions thrown from the closeables are suppressed.closeables - the closeables arraypublic static void closeSilently(@Nullable
java.lang.Object o)
o - an objectpublic static void close(java.io.Closeable... closeables)
throws MultiIOException
closeables - the array of closeablesMultiIOException - if one or more close() calls threwpublic static void close(java.lang.Iterable<? extends java.io.Closeable> closeables)
throws MultiIOException
closeables - the sequence of closeablesMultiIOException - if one or more close() calls threwpublic static void close(java.lang.Object o)
throws java.io.IOException
o - the object to closejava.io.IOException - the exception thrown by the close() method@Nonnull
public static java.io.Closeable toCloseable(@Nonnull
Action0 action)
action - the action to wrap@Nonnull
public static java.io.Closeable toCloseable(@Nonnull
Action0E<? extends java.io.IOException> action)
action - the action to wrap