`
vortexchoo
  • 浏览: 64033 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

关闭流方法笔记

    博客分类:
  • java
阅读更多
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接口。

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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics