Refactoring

This commit is contained in:
M66B 2021-10-12 19:31:55 +02:00
parent 740355cb18
commit 627a9faba6
1 changed files with 9 additions and 9 deletions

View File

@ -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();