From 627a9faba6aa7db5e990eb2a2f8c1a6266612d15 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 12 Oct 2021 19:31:55 +0200 Subject: [PATCH] Refactoring --- .../main/java/eu/faircode/email/Helper.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 9db19218f0..d1aacdbada 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -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();