Here you can find the source of close(final Logger logger, final Closeable... closeables)
Parameter | Description |
---|---|
logger | Logger instance, can be <code>null</code> if logging not required |
closeables | Closeable array |
public static void close(final Logger logger, final Closeable... closeables)
//package com.java2s; //License from project: Open Source License import java.io.Closeable; import java.io.IOException; import org.slf4j.Logger; public class Main { /**/*w w w . j av a2 s .co m*/ * Close {@link Closeable} resource. * * @param closeables * {@link Closeable} array */ public static void close(final Closeable... closeables) { close(null, closeables); } /** * Close {@link Closeable} resource. * * @param logger * {@link Logger} instance, can be <code>null</code> if logging not required * @param closeables * {@link Closeable} array */ public static void close(final Logger logger, final Closeable... closeables) { if (closeables == null || closeables.length == 0) return; for (final Closeable c : closeables) if (c != null) try { c.close(); } catch (final IOException e) { if (logger != null && logger.isDebugEnabled()) logger.debug("Closing[" + c + "] fail", e); } } }