Modifier and Type | Method and Description |
---|---|
static void |
closeAll(Iterable<? extends Closeable> iterable)
Allows you to close as many of the
Closeable s as possible. |
static IOException |
closeAllQuietly(Iterable<? extends Closeable> iterable) |
static IOException |
closeQuietly(Closeable closeable)
Close a
Closeable , returning an IOException if it occurs while closing
instead of throwing it. |
public static IOException closeQuietly(@Nullable Closeable closeable)
Closeable
, returning an IOException
if it occurs while closing
instead of throwing it. This is nearly a clone of the Guava Closeables.closeQuietly method
which has long since been removed from Guava.
Use of this method should be avoided -- quietly swallowing IOExceptions (particularly on
Closeables that are being written to) is a code smell. Use of the equivalent method in
Guava was done for this reason.closeable
- the Closeable to be closed, can be nullnull
public static void closeAll(Iterable<? extends Closeable> iterable) throws IOException
Closeable
s as possible.
If any of the close's fail with an IOException, those exception(s) will
be thrown after attempting to close all of the inputs.IOException
public static IOException closeAllQuietly(Iterable<? extends Closeable> iterable)
Copyright © 2015 Apache Software Foundation. All Rights Reserved.