java关闭流连接IO工具类
更新:HHH   时间:2023-1-7


本文实例为大家分享了java关闭流连接IO工具类的具体代码,供大家参考,具体内容如下

package com.demo.utils;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;

/**
 * 关闭流连接IO工具类
 * @author dongyangyang
 * @Date 2016/12/28 23:12
 * @Version 1.0
 *
 */
public class IOUtils {

 public static void close(InputStream in) {
  if (in != null) {
   try {
    in.close();
   } catch (IOException e) {

   }
  }
 }

 public static void close(OutputStream out){
  if (out != null) {
   try {
    out.close();
   } catch (IOException e) {

   }
  }
 }

 public static void close(Reader r) {
  if (r != null) {
   try {
    r.close();
   } catch (IOException e) {

   }
  }
 }

 public static void close(Writer w){
  if (w != null) {
   try {
    w.close();
   } catch (IOException e) {

   }
  }
 }
}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持天达云。

返回编程语言教程...