1package com.wazn.learn.util; 2 3 4import java.io.Closeable; 5import java.io.IOException; 6 7/** 8 * IO流工具类 9 * 10 * @author yangzhenyu 11 * 12 */ 13public class IOUtil { 14 /** 15 * 关闭一个或多个流对象 16 * 17 * @param closeables 18 * 可关闭的流对象列表 19 * @throws IOException 20 */ 21 public static void close(Closeable... closeables) throws IOException { 22 if (closeables != null) { 23 for (Closeable closeable : closeables) { 24 if (closeable != null) { 25 closeable.close(); 26 } 27 } 28 } 29 } 30 31 /** 32 * 关闭一个或多个流对象 33 * 34 * @param closeables 35 * 可关闭的流对象列表 36 */ 37 public static void closeQuietly(Closeable... closeables) { 38 try { 39 close(closeables); 40 } catch (IOException e) { 41 // do nothing 42 } 43 } 44 45}
Java常用工具类之IO流工具类
Wesley13
2021-10-11
1084 0 0
点赞
收藏
评论区
加载中...