blob: 7f74725c5197ec9ea0ea41d6446078e5a797e3fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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;
}
}
|