forked from External/mage
fixed unclosed resources in copy method in mage framework Copier
This commit is contained in:
parent
91b538be63
commit
dc25eedfc3
3 changed files with 42 additions and 5 deletions
30
Mage/src/main/java/mage/util/StreamUtils.java
Normal file
30
Mage/src/main/java/mage/util/StreamUtils.java
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package mage.util;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
public final class StreamUtils {
|
||||
|
||||
/***
|
||||
* Quietly closes the closable, ignoring nulls and exceptions
|
||||
* @param c - the closable to be closed
|
||||
*/
|
||||
public static void closeQuietly(Closeable c) {
|
||||
if (c != null) {
|
||||
try {
|
||||
c.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeQuietly(AutoCloseable ac) {
|
||||
if (ac != null) {
|
||||
try {
|
||||
ac.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue