优雅写法

工具类

优雅关闭流

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.io.Closeable;
import java.io.IOException;

/**
* 说明:关闭流的类
*
* @author shenbh
* time 2021-10-15 15:41
*/
public class CloseableUtil {
public static void close(Closeable closeable){
try {
if (closeable != null){
closeable.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}