本文實例為大家分享了java關閉流連接IO工具類的具體代碼,供大家參考,具體內容如下
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
55
56
57
|
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) { } } } } |
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。
原文鏈接:https://blog.csdn.net/qq_35712358/article/details/70256785