Class FileUtils


  • public class FileUtils
    extends FileUtils
    Author:
    jerrickpua
    • Field Detail

      • fileSizeUnits

        static String[] fileSizeUnits
    • Constructor Detail

      • FileUtils

        public FileUtils()
    • Method Detail

      • getCurrentDriveUsableSpace

        public static long getCurrentDriveUsableSpace​(FileUtils.UNITS unit)
      • getCurrentDriveUsableSpace

        public static long getCurrentDriveUsableSpace()
      • getCurrentDriveFreeSpace

        public static long getCurrentDriveFreeSpace​(FileUtils.UNITS unit)
      • getCurrentDriveFreeSpace

        public static long getCurrentDriveFreeSpace()
      • getCurrentDriveTotalSpace

        public static long getCurrentDriveTotalSpace​(FileUtils.UNITS unit)
      • getCurrentDriveTotalSpace

        public static long getCurrentDriveTotalSpace()
      • getCurrentDriveUsedSpace

        public static long getCurrentDriveUsedSpace​(FileUtils.UNITS unit)
      • getCurrentDriveUsedSpace

        public static long getCurrentDriveUsedSpace()
      • changeExtension

        public static File changeExtension​(File file,
                                           String extension)
      • isSystemGeneratedFile

        public static com.google.common.base.Predicate<File> isSystemGeneratedFile()
      • isEmptyDirectory

        public static boolean isEmptyDirectory​(File directory)
      • isEmptyDirectory

        public static boolean isEmptyDirectory​(File directory,
                                               FileFilter filter)
      • unhideFile

        public static boolean unhideFile​(File file)
      • hideFile

        public static boolean hideFile​(File file)
      • deleteEmptyFolder

        public static void deleteEmptyFolder​(File directory,
                                             File stopAtDirectory)
        Recursively delete directory if found empty. This delete operation will start from child up to stopAtDirectory.
        Parameters:
        directoryStart - directory
        stopAtDirectory - stopper directory. This is required to prevent the method delete all file up to file system's root directory
        Throws:
        IllegalArgumentException - if no stopper directory is defined
        Since:
        2.0
      • megabyteCountToDisplaySize

        public static String megabyteCountToDisplaySize​(double megabyte)
      • isChildOf

        public static boolean isChildOf​(String parent,
                                        String child)
        Checks if the given child directory is a child of the given parent directory
        Parameters:
        parent - parent directory
        child - child directory
        Returns:
        true if child is a child directory of the given parent
      • getNameWithoutExtension

        public static String getNameWithoutExtension​(File file)
      • getNameWithoutExtension

        public static String getNameWithoutExtension​(String fileName)