想了解java关闭流连接IO工具类的相关内容吗,Smile_Pride在本文为您仔细讲解java关闭流连接IO工具类的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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) {
}
}
}
}