Class FileUtils
java.lang.Object
utils.FileUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doublebytesToGiB(long bytes) Converts bytes to GiBsstatic StringgetFileHash(org.bouncycastle.crypto.digests.SHA256Digest digest, byte[] buffer, byte[] bytes) Returns the hash of the bytes passed to itstatic StringgetRecursiveHash(File root) Unpacks a file tree into a list, calculates the files, adds them together and returns itstatic longgetUsedSpace(File file) Gets the amount of used spaces by a file and its sub-files (recursively) in bytes
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
bytesToGiB
public static double bytesToGiB(long bytes) Converts bytes to GiBs- Parameters:
bytes- the bytes to convert- Returns:
- The value converted to GiB
-
getUsedSpace
Gets the amount of used spaces by a file and its sub-files (recursively) in bytes- Parameters:
file- The parent file to use- Returns:
- The used space in bytes
-
getRecursiveHash
Unpacks a file tree into a list, calculates the files, adds them together and returns it- Parameters:
root- The root of the file tree to use- Returns:
- The aggregated hash of the file tree
- Throws:
IOException- if an error with reading the file occurs
-
getFileHash
public static String getFileHash(org.bouncycastle.crypto.digests.SHA256Digest digest, byte[] buffer, byte[] bytes) Returns the hash of the bytes passed to it- Parameters:
digest- The digest to usebuffer- The buffer for the hashbytes- The data that is hashed- Returns:
- The hash as a hex string
-