diff options
Diffstat (limited to 'src/java/com/jogamp/common/util/IOUtil.java')
-rw-r--r-- | src/java/com/jogamp/common/util/IOUtil.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java index 9e803cb..0463c37 100644 --- a/src/java/com/jogamp/common/util/IOUtil.java +++ b/src/java/com/jogamp/common/util/IOUtil.java @@ -30,6 +30,7 @@ package com.jogamp.common.util; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; +import java.io.Closeable; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -585,4 +586,19 @@ public class IOUtil { } throw new IOException("Could not create temp directory @ "+tempRoot.getAbsolutePath()+tmpDirPrefix+"_*"); } + + public static void close(Closeable stream, boolean throwRuntimeException) throws RuntimeException { + if(null != stream) { + try { + stream.close(); + } catch (IOException e) { + if(throwRuntimeException) { + throw new RuntimeException(e); + } else if(DEBUG) { + System.err.println("Catched Exception: "); + e.printStackTrace(); + } + } + } + } } |