public class Closeables
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.io.Closeable |
NO_OP
A closeable which does nothing
|
Constructor and Description |
---|
Closeables() |
Modifier and Type | Method and Description |
---|---|
static <T> CloseableProvider<T> |
closeableProvider(T object) |
static <T> CloseableProvider<T> |
closeableProvider(T object,
java.io.Closeable closer) |
static void |
closeAll(boolean throwIOException,
boolean throwLast,
java.io.Closeable... closeables) |
static void |
closeAll(java.io.Closeable... closeables)
Close all closeables and throw any final exception
|
static void |
closeAll(java.util.Collection<java.io.Closeable> closeables) |
static java.io.Closeable |
closeOnce(java.io.Closeable closer) |
static void |
closeQuietly(java.io.Closeable... closeables)
Close all closeables quietly
|
static void |
closeQuietly(java.util.Collection<java.io.Closeable> closeables) |
static java.io.Closeable |
maybeCloseable(java.lang.Object object)
If the input object is a Closeable, return it, otherwise return a non-null Closeable which does nothing.
|
static java.io.Closeable |
single(boolean throwIOException,
boolean throwLast,
java.io.Closeable... closeables)
Create a single Closeable which closes all of the specified closeables
|
static java.io.Closeable |
single(boolean throwIOException,
java.io.Closeable... closeables)
Create a single Closeable which closes all of the specified closeables
|
static java.io.Closeable |
single(boolean throwIOException,
java.util.Collection<java.io.Closeable> closeables)
Create a single Closeable which closes all of the specified closeables
|
static java.io.Closeable |
single(java.io.Closeable... closeables)
Create a single Closeable which closes all of the specified closeables and throws IOExceptions
|
static java.io.Closeable |
single(java.util.Collection<java.io.Closeable> closeables)
Create a single Closeable which closes all of the specified closeables and throws IOExceptions
|
public static <T> CloseableProvider<T> closeableProvider(T object)
public static java.io.Closeable closeOnce(java.io.Closeable closer)
public static <T> CloseableProvider<T> closeableProvider(T object, java.io.Closeable closer)
public static java.io.Closeable maybeCloseable(java.lang.Object object)
object
- object which might be closeablepublic static java.io.Closeable single(boolean throwIOException, java.util.Collection<java.io.Closeable> closeables)
throwIOException
- if true, throw any IOException encounteredcloseables
- collection of closeablespublic static java.io.Closeable single(java.util.Collection<java.io.Closeable> closeables)
closeables
- closeablespublic static java.io.Closeable single(java.io.Closeable... closeables)
closeables
- closeablespublic static java.io.Closeable single(boolean throwIOException, java.io.Closeable... closeables)
throwIOException
- if true, throw the final IOException encounteredcloseables
- array of closeablespublic static java.io.Closeable single(boolean throwIOException, boolean throwLast, java.io.Closeable... closeables)
throwIOException
- if true, throw an IOException if encountered, otherwise do not throw anythingthrowLast
- if true, only throw the last IOException encountered, otherwise throw the firstcloseables
- array of closeablespublic static void closeQuietly(java.util.Collection<java.io.Closeable> closeables)
public static void closeAll(java.util.Collection<java.io.Closeable> closeables) throws java.io.IOException
java.io.IOException
public static void closeAll(java.io.Closeable... closeables) throws java.io.IOException
closeables
- java.io.IOException
public static void closeQuietly(java.io.Closeable... closeables)
closeables
- public static void closeAll(boolean throwIOException, boolean throwLast, java.io.Closeable... closeables) throws java.io.IOException
java.io.IOException