1 | void close(Writer device) {↵ | | 1 | void close(Reader device) {↵
|
2 | if (device != null) {↵ | | 2 | if (device != null) {↵
|
3 | try {↵ | | 3 | try {↵
|
4 | device.close();↵ | | 4 | device.close();↵
|
5 | } catch (IOException ioex) {↵ | | 5 | } catch (IOException ioex) {↵
|
6 | //ignore↵ | | 6 | //ignore↵
|
7 | }↵ | | 7 | }↵
|
8 | }↵ | | 8 | }↵
|
9 | }↵ | | 9 | }↵
|
|
10 | /**↵ | | 10 | /**↵
|
11 | * Close a stream without throwing any exception if something went wrong.↵ | | 11 | * Close a stream without throwing any exception if something went wrong.↵
|
12 | * Do not attempt to close it if the argument is null.↵ | | 12 | * Do not attempt to close it if the argument is null.↵
|
13 | *↵ | | 13 | *↵
|
14 | * @param device Reader, can be null.↵ | | 14 | * @param device stream, can be null.↵
|
15 | */↵ | | 15 | */↵
|
16 | public static void close(Reader device) {↵ | | 16 | public static void close(OutputStream device) {↵
|
17 | if (device != null) {↵ | | 17 | if (device != null) {↵
|
18 | try {↵ | | 18 | try {↵
|
19 | device.close();↵ | | 19 | device.close();↵
|
20 | } catch (IOException ioex) {↵ | | 20 | } catch (IOException ioex) {↵
|
21 | //ignore↵ | | 21 | //ignore↵
|
22 | }↵ | | 22 | }↵
|
23 | }↵ | | 23 | }↵
|
24 | }↵ | | 24 | }↵
|
|
25 | /**↵ | | 25 | /**↵
|
26 | * Close a stream without throwing any exception if something went wrong.↵ | | 26 | * Close a stream without throwing any exception if something went wrong.↵
|
27 | * Do not attempt to close it if the argument is null.↵ | | 27 | * Do not attempt to close it if the argument is null.↵
|
28 | *↵ | | 28 | *↵
|
29 | * @param device stream, can be null.↵ | | 29 | * @param device stream, can be null.↵
|
30 | */↵ | | 30 | */↵
|
31 | public static void close(OutputStream device) {↵ | | 31 | public static void close(InputStream device) {↵
|
32 | if (device != null) {↵ | | 32 | if (device != null) {↵
|
33 | try {↵ | | 33 | try {↵
|
34 | device.close();↵ | | 34 | device.close();↵
|
35 | } catch (IOException ioex) {↵ | | 35 | } catch (IOException ioex) {↵
|
36 | //ignore↵ | | 36 | //ignore↵
|
37 | }↵ | | 37 | }↵
|
38 | }↵ | | 38 | }↵
|
39 | | | 39 |
|