From 08ac6aaea58b7309ea95a12ca6227a6ca3ce4db5 Mon Sep 17 00:00:00 2001 From: Keuin Date: Mon, 25 Jan 2021 15:25:34 +0800 Subject: Improve user interaction. Code refactor. --- .../java/com/keuin/kbackupfabric/util/FilesystemUtil.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java') diff --git a/src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java b/src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java index f245cff..bccd403 100644 --- a/src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java +++ b/src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java @@ -15,19 +15,22 @@ public class FilesystemUtil { */ public static long getFileSizeBytes(String parentDirectory, String fileName) { long fileSize = -1; - try{ + try { File backupZipFile = new File(parentDirectory, fileName); fileSize = backupZipFile.length(); - } catch (SecurityException ignored){ + } catch (SecurityException ignored) { } return fileSize; } public static long getFileSizeBytes(String filePath) { + return getFileSizeBytes(new File(filePath)); + } + + public static long getFileSizeBytes(File file) { long fileSize = -1; try { - File backupZipFile = new File(filePath); - fileSize = backupZipFile.length(); + fileSize = file.length(); } catch (SecurityException ignored) { } return fileSize; -- cgit v1.2.3