ITeye博客

关闭流方法笔记

vortexchoo · 2015-09-01 09:19 · java · 编程语言 · Markdown

public class CloseHelper {
	
	public static void closeStreams(Closeable... streams) throws IOException{
		for(Closeable c:streams){
			if(c!=null){
				c.close();
			}
		}
	}
	
}

 此方法用于关闭常用的inputstream / outputstream 。 可以看出,常用的inputstream / outputstream 都是继承了closeable接口。

传入参数是数组形式,因此需要遍历关闭。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。