diff options
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java')
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java b/src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java new file mode 100644 index 0000000..7f74725 --- /dev/null +++ b/src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java @@ -0,0 +1,33 @@ +package com.keuin.kbackupfabric.util; + +import java.io.File; + +public class FilesystemUtil { + + /** + * Get file sizes in bytes. + * @param parentDirectory path to specific file. + * @param fileName file name. + * @return bytes. If failed, return -1. + */ + public static long getFileSizeBytes(String parentDirectory, String fileName) { + long fileSize = -1; + try{ + File backupZipFile = new File(parentDirectory, fileName); + fileSize = backupZipFile.length(); + } catch (SecurityException ignored){ + } + return fileSize; + } + + public static long getFileSizeBytes(String filePath) { + long fileSize = -1; + try{ + File backupZipFile = new File(filePath); + fileSize = backupZipFile.length(); + } catch (SecurityException ignored){ + } + return fileSize; + } + +} |