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

Wesley131160 阅读
文章目录
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
}
}
}
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论