从Hadoop IOUtils closeStream方法看如何安全关闭流

    xiaoxiao2025-10-28  10

    使用方法

    IOUtils.closeStream(writer);

    进入代码

    public static void closeStream(java.io.Closeable stream) { cleanup(null, stream); } public static void cleanup(Log log, java.io.Closeable... closeables) { for (java.io.Closeable c : closeables) { if (c != null) { try { c.close(); } catch(IOException e) { if (log != null && log.isDebugEnabled()) { log.debug("Exception in closing " + c, e); } } } } }
    最新回复(0)