package com.wazn.learn.util; import java.io.Closeable; import java.io.IOException; /** * IO流工具類 * * @author yangzhenyu * */ public class IOUtil { /** * 關閉一個或多個流對象 * * @param closeables * 可關閉的流對象列表 * @throws IOException */ public static void close(Closeable... closeables) throws IOException { if (closeables != null) { for (Closeable closeable : closeables) { if (closeable != null) { closeable.close(); } } } } /** * 關閉一個或多個流對象 * * @param closeables * 可關閉的流對象列表 */ public static void closeQuietly(Closeable... closeables) { try { close(closeables); } catch (IOException e) { // do nothing } } }