fixed unclosed resources in copy method in mage framework Copier

This commit is contained in:
Marc Zwart 2018-03-20 14:18:42 +01:00
parent 91b538be63
commit dc25eedfc3
3 changed files with 42 additions and 5 deletions

View 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) {
}
}
}
}