-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
/
CloseUtils.java
54 lines (49 loc) · 1.28 KB
/
CloseUtils.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.blankj.utilcode.util;
import java.io.Closeable;
import java.io.IOException;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2016/10/09
* desc : utils about close
* </pre>
*/
public final class CloseUtils {
private CloseUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
/**
* Close the io stream.
*
* @param closeables The closeables.
*/
public static void closeIO(final Closeable... closeables) {
if (closeables == null) return;
for (Closeable closeable : closeables) {
if (closeable != null) {
try {
closeable.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* Close the io stream quietly.
*
* @param closeables The closeables.
*/
public static void closeIOQuietly(final Closeable... closeables) {
if (closeables == null) return;
for (Closeable closeable : closeables) {
if (closeable != null) {
try {
closeable.close();
} catch (IOException ignored) {
}
}
}
}
}