diff options
Diffstat (limited to 'netx/net/sourceforge/jnlp/util/StreamUtils.java')
-rw-r--r-- | netx/net/sourceforge/jnlp/util/StreamUtils.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/netx/net/sourceforge/jnlp/util/StreamUtils.java b/netx/net/sourceforge/jnlp/util/StreamUtils.java index ed92fb6..3a179d5 100644 --- a/netx/net/sourceforge/jnlp/util/StreamUtils.java +++ b/netx/net/sourceforge/jnlp/util/StreamUtils.java @@ -37,6 +37,7 @@ exception statement from your version. package net.sourceforge.jnlp.util; +import java.io.Closeable; import java.io.IOException; import java.io.InputStream; @@ -55,4 +56,19 @@ public class StreamUtils { in.close(); } -}
\ No newline at end of file + /*** + * Closes a stream, without throwing IOException. + * In case of IOException, prints the stack trace to System.err. + * + * @param stream the stream that will be closed + */ + public static void closeSilently (Closeable stream) { + if (stream != null) { + try { + stream.close(); + } catch (IOException e) { + e.printStackTrace(System.err); + } + } + } +} |