Here you can find the source of close(Collection
public static void close(Collection<Closeable> inCloseables)
//package com.java2s; //License from project: Open Source License import java.io.Closeable; import java.io.IOException; import java.io.OutputStream; import java.io.Writer; import java.util.Collection; public class Main { public static void close(Closeable inCloseable) { close(inCloseable, false);/*from ww w . j a v a 2 s . com*/ } public static void close(Closeable inCloseable, boolean inFlush) { if (inFlush) { flush(inCloseable); } try { inCloseable.close(); } catch (final Exception e) { } } public static void close(Closeable... inCloseable) { if (inCloseable != null) { for (final Closeable closeable : inCloseable) { close(closeable); } } } public static void close(Collection<Closeable> inCloseables) { if (inCloseables != null) { for (final Closeable closeable : inCloseables) { close(closeable); } } } public static void flush(OutputStream inOutputStream) { try { inOutputStream.flush(); } catch (final IOException e) { // swallow } } public static void flush(Writer inWriter) { try { inWriter.flush(); } catch (final IOException e) { // swallow } } public static void flush(Object inOut) { if (inOut instanceof OutputStream) { flush((OutputStream) inOut); } else if (inOut instanceof Writer) { flush((Writer) inOut); } } }