close stream utility class

package cn.weida.io.others;
import java.io.Closeable;
import java.io.IOException;
public class fileCloseUtils {
  
 
 /**
  * 工具关闭类
  * 可变参数   形参最后
  *
  *fileCloseUtils.close(i,s,x);
  * @param io
  */
 public  static void close(Closeable ... io) {
  for(Closeable temp: io) {
   try {
    if (null != temp)
     temp.close();
   } catch (IOException e) {
    e.printStackTrace();
   }
  }
 }
 
 /**
  *
  * @param io
  */
 public  static <T extends Closeable> void closeAll(T ... io)  {
  for(Closeable temp: io) {
   try {
    if (null != temp)
     temp.close();
   } catch (IOException e) {
    e.printStackTrace();
   }
  }
 }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325402943&siteId=291194637