소스 검색

Add support for closing Sockets (could be removed if we switched to Java7)

Change-Id: I34aa3a772f7f777aa31ca6a243ad51bdc86fbb8e
Reviewed-on: http://gerrit.dmdirc.com/2462
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.7rc1
Greg Holmes 12 년 전
부모
커밋
093f9e66e9
1개의 변경된 파일17개의 추가작업 그리고 0개의 파일을 삭제
  1. 17
    0
      src/com/dmdirc/util/io/StreamUtils.java

+ 17
- 0
src/com/dmdirc/util/io/StreamUtils.java 파일 보기

24
 
24
 
25
 import java.io.Closeable;
25
 import java.io.Closeable;
26
 import java.io.IOException;
26
 import java.io.IOException;
27
+import java.net.Socket;
27
 
28
 
28
 /**
29
 /**
29
  * Utilities for dealing with streams.
30
  * Utilities for dealing with streams.
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
 }

Loading…
취소
저장