diff options
| author | Simon Rettberg | 2015-06-02 19:53:31 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2015-06-02 19:53:31 +0200 |
| commit | 1bc83891c68ee269727e81a13cc70da698bcc7a7 (patch) | |
| tree | b052a72ad7d65864068752f71c5ed2b49a171276 /dozentenmodulserver/src/main/java/util/Util.java | |
| parent | [server] Started work on the internal file server (diff) | |
| download | tutor-module-1bc83891c68ee269727e81a13cc70da698bcc7a7.tar.gz tutor-module-1bc83891c68ee269727e81a13cc70da698bcc7a7.tar.xz tutor-module-1bc83891c68ee269727e81a13cc70da698bcc7a7.zip | |
[server] Compiling again, still lots of stubs
Diffstat (limited to 'dozentenmodulserver/src/main/java/util/Util.java')
| -rw-r--r-- | dozentenmodulserver/src/main/java/util/Util.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/dozentenmodulserver/src/main/java/util/Util.java b/dozentenmodulserver/src/main/java/util/Util.java new file mode 100644 index 00000000..28f522b8 --- /dev/null +++ b/dozentenmodulserver/src/main/java/util/Util.java @@ -0,0 +1,45 @@ +package util; + +import java.io.Closeable; + +public class Util { + + /** + * Try to close everything passed to this method. Never throw an exception + * if it fails, just silently continue. + * + * @param item One or more objects that are Closeable + */ + public static void safeClose(Closeable... item) { + if (item == null) + return; + for (Closeable c : item) { + if (c == null) + continue; + try { + c.close(); + } catch (Exception e) { + } + } + } + + /** + * Try to close everything passed to this method. Never throw an exception + * if it fails, just silently continue. + * + * @param item One or more objects that are AutoCloseable + */ + public static void safeClose(AutoCloseable... item) { + if (item == null) + return; + for (AutoCloseable c : item) { + if (c == null) + continue; + try { + c.close(); + } catch (Exception e) { + } + } + } + +} |
