Refactoring

pull/206/head
M66B 3 years ago
parent 740355cb18
commit 627a9faba6

@ -1633,12 +1633,20 @@ public class Helper {
static void copy(File src, File dst) throws IOException {
try (InputStream is = new FileInputStream(src)) {
try (FileOutputStream os = new FileOutputStream(dst)) {
try (OutputStream os = new FileOutputStream(dst)) {
copy(is, os);
}
}
}
static long copy(Context context, Uri uri, File file) throws IOException {
try (InputStream is = context.getContentResolver().openInputStream(uri)) {
try (OutputStream os = new FileOutputStream(file)) {
return copy(is, os);
}
}
}
static long copy(InputStream is, OutputStream os) throws IOException {
long size = 0;
byte[] buf = new byte[BUFFER_SIZE];
@ -1650,14 +1658,6 @@ public class Helper {
return size;
}
static long copy(Context context, Uri uri, File file) throws IOException {
try (InputStream is = context.getContentResolver().openInputStream(uri)) {
try (OutputStream os = new FileOutputStream(file)) {
return copy(is, os);
}
}
}
static long getAvailableStorageSpace() {
StatFs stats = new StatFs(Environment.getDataDirectory().getAbsolutePath());
return stats.getAvailableBlocksLong() * stats.getBlockSizeLong();

Loading…
Cancel
Save