Files
v2rayNG/V2rayNG/dpreference/src/main/java/me/dozen/dpreference/IOUtils.java
T
2dust 2d8ed22dba mge
2019-10-11 14:17:10 +08:00

62 lines
1.3 KiB
Java

package me.dozen.dpreference;
import android.database.Cursor;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
final class IOUtils {
// NOTE: This class is focussed on InputStream, OutputStream, Reader and
// Writer. Each method should take at least one of these as a parameter,
// or return one of them.
private static final int EOF = -1;
/**
* The default buffer size ({@value}) to use for {@link
*/
private static final int DEFAULT_BUFFER_SIZE = 1024;
public static void closeQuietly(InputStream is) {
if (is != null) {
try {
is.close();
} catch (IOException e) {
// ignore
}
}
}
public static void closeQuietly(OutputStream os) {
if (os != null) {
try {
os.close();
} catch (IOException e) {
// ignore
}
}
}
public static void closeQuietly(Reader r) {
if (r != null) {
try {
r.close();
} catch (IOException e) {
// ignore
}
}
}
public static void closeQuietly(Cursor cursor) {
if (cursor != null && !cursor.isClosed()) {
cursor.close();
}
}
}