| | | 1 | void closeQuietly(InputStream is){↵
|
| | | 2 | try {↵
|
| | | 3 | if (is != null) {↵
|
| | | 4 | is.close();↵
|
| | | 5 | }↵
|
| | | 6 | } catch (IOException ignored) {↵
|
| | | 7 | }↵
|
| | | 8 | }↵
|
|
| | | 9 | /**↵
|
| | | 10 | * close a stream with no error thrown↵
|
| | | 11 | * @param os - OutputStream (may be null)↵
|
| | | 12 | */↵
|
1 | void closeQuietly(OutputStream os){↵ | | 13 | public static void closeQuietly(OutputStream os){↵
|
2 | try {↵ | | 14 | try {↵
|
3 | if (os != null) {↵ | | 15 | if (os != null) {↵
|
4 | os.close();↵ | | 16 | os.close();↵
|
5 | }↵ | | 17 | }↵
|
6 | } catch (IOException ignored) {↵ | | 18 | } catch (IOException ignored) {↵
|
7 | }↵ | | 19 | }↵
|
8 | }↵ | | 20 | }↵
|
|
9 | /**↵ | | 21 | /**↵
|
10 | * close a Writer with no error thrown↵ | | 22 | * close a Writer with no error thrown↵
|
11 | * @param wr - Writer (may be null)↵ | | 23 | * @param wr - Writer (may be null)↵
|
12 | */↵ | | 24 | */↵
|
13 | public static void closeQuietly(Writer wr){↵ | | 25 | public static void closeQuietly(Writer wr){↵
|
14 | try {↵ | | 26 | try {↵
|
15 | if (wr != null) {↵ | | 27 | if (wr != null) {↵
|
16 | wr.close();↵ | | 28 | wr.close();↵
|
17 | }↵ | | 29 | }↵
|
18 | } catch (IOException ignored) {↵ | | 30 | } catch (IOException ignored) {↵
|
19 | }↵ | | 31 | }↵
|
20 | }↵ | | 32 | }↵
|
|
21 | /**↵ | | 33 | /**↵
|
22 | * close a Reader with no error thrown↵ | | 34 | * close a Reader with no error thrown↵
|
23 | * @param rd - Reader (may be null)↵ | | 35 | * @param rd - Reader (may be null)↵
|
24 | */↵ | | 36 | */↵
|
25 | public static void closeQuietly(Reader rd){↵ | | 37 | public static void closeQuietly(Reader rd){↵
|
26 | try {↵ | | 38 | try {↵
|
27 | if (rd != null) {↵ | | 39 | if (rd != null) {↵
|
28 | rd.close();↵ | | 40 | rd.close();↵
|
29 | }↵ | | 41 | }↵
|
30 | } catch (IOException ignored) {↵ | | 42 | } catch (IOException ignored) {↵
|
31 | }↵ | | 43 | }↵
|
32 | }↵ | | 44 |
|
|
33 | /**↵ | | | |
34 | * close a Socket with no error thrown↵ | | | |
35 | * @param sock - Socket (may be null)↵ | | | |
36 | */↵ | | | |
37 | public static void closeQuietly(Socket sock){↵ | | | |
38 | try {↵ | | | |
39 | if (sock!= null) {↵ | | | |
40 | sock.close();↵ | | | |
41 | }↵ | | | |
42 | } catch (IOException ignored) {↵ | | | |
43 | }↵ | | | |
44 | | | | |