public final class Closeables extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
closeAll(Iterable<? extends Closeable> closeables) |
static void |
closeQuietly(Closeable closeable) |
static <T> T |
wrapResource(Callable<T> wrapperFactory,
Closeable resource)
Create a wrapper for
resource. |
public static void closeQuietly(Closeable closeable)
public static void closeAll(Iterable<? extends Closeable> closeables) throws IOException
IOExceptionpublic static <T> T wrapResource(Callable<T> wrapperFactory, Closeable resource) throws IOException
resource. If wrapper fail to be created, resource is properly closed.
In the case if wrapperFactory.call() succeed, returned object is responsible to close resource.T - wrapper object typewrapperFactory - wrapper factoryresource - resource used by wrapperIOException - in the case of any exception.Copyright © 2011–2020. All rights reserved.