Java常用工具类之IO流工具类

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
        }
    }
 
}

 

posted @ 2018-01-18 16:39  谁将新樽辞旧月,今月曾经照古人  阅读(327)  评论(0编辑  收藏  举报