|
@@ -24,6 +24,7 @@ package com.dmdirc.util.io;
|
24
|
24
|
|
25
|
25
|
import java.io.Closeable;
|
26
|
26
|
import java.io.IOException;
|
|
27
|
+import java.net.Socket;
|
27
|
28
|
|
28
|
29
|
/**
|
29
|
30
|
* Utilities for dealing with streams.
|
|
@@ -53,4 +54,20 @@ public final class StreamUtils {
|
53
|
54
|
}
|
54
|
55
|
}
|
55
|
56
|
|
|
57
|
+ /**
|
|
58
|
+ * Closes the stream if it is non-null, and ignores any IOExceptions
|
|
59
|
+ * raised by doing so.
|
|
60
|
+ *
|
|
61
|
+ * @param stream The stream to be closed
|
|
62
|
+ */
|
|
63
|
+ public static void close(final Socket stream) {
|
|
64
|
+ if (stream != null) {
|
|
65
|
+ try {
|
|
66
|
+ stream.close();
|
|
67
|
+ } catch (IOException ex) {
|
|
68
|
+ // Do nothing. We don't care.
|
|
69
|
+ }
|
|
70
|
+ }
|
|
71
|
+ }
|
|
72
|
+
|
56
|
73
|
}
|