Class FileUtils

java.lang.Object
utils.FileUtils

public class FileUtils extends Object
  • 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

      public static long getUsedSpace(File file)
      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

      public static String getRecursiveHash(File root) throws IOException
      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 use
      buffer - The buffer for the hash
      bytes - The data that is hashed
      Returns:
      The hash as a hex string