ADD: IoUtils.

This commit is contained in:
Oasis 2016-11-10 18:04:26 +08:00
parent f70a4a6f79
commit 8cd9333078

View File

@ -0,0 +1,28 @@
package com.oasisfeng.java.utils;
import android.support.annotation.Nullable;
import java.io.Closeable;
import java.io.InputStream;
/** Simple static methods to perform common IO operations. */
public final class IoUtils {
public static void closeQuietly(final @Nullable Closeable closeable) {
if (closeable == null) return;
try {
closeable.close();
} catch (final RuntimeException e) {
throw e;
} catch (final Exception ignored) {}
}
public static void closeQuietly(final @Nullable InputStream stream) {
if (stream == null) return;
try {
stream.close();
} catch (final RuntimeException e) {
throw e;
} catch (final Exception ignored) {}
}
}