---
title: "关闭流方法笔记"
author: "vortexchoo"
date: "2015-09-01T09:19:18Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2015-09-01T09:19:18Z"
id: 2239850
url: "https://vortexchoo.iteye.com/blog/2239850"
---

```
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接口。

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