forked from AlEinstein/javaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIOUtil.java
More file actions
48 lines (41 loc) · 1.21 KB
/
Copy pathIOUtil.java
File metadata and controls
48 lines (41 loc) · 1.21 KB
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
package common.utils;
import common.enumeration.errorMessageEnum.ErrorMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Closeable;
import java.io.IOException;
/**
* Create by mulin on 2018/12/13.
*/
public class IOUtil {
private static Logger logger = LoggerFactory.getLogger(IOUtil.class);
/**
* 关闭一个或多个流对象
*
* @param closeables 可关闭的流对象列表
* @throws IOException
*/
public static void close(Closeable... closeables) throws IOException {
if (closeables != null) {
for (Closeable closeable : closeables) {
if (closeable != null) {
closeable.close();
}
}
}
}
/**
* 关闭一个或多个流对象
*
* @param closeables 可关闭的流对象列表
* @throws IOException
*/
public static void closeQuietly(Closeable... closeables) throws IOException {
try {
close(closeables);
} catch (IOException e) {
logger.error(ErrorMessage.IOFILE_CLOSE_ERROR.getErrorInfo());
throw new IOException(ErrorMessage.IOFILE_CLOSE_ERROR.getErrorInfo());
}
}
}