Class FileUtil


  • public final class FileUtil
    extends Object
    Utility methods for file handling.
    • Method Detail

      • getCanonicalPath

        public static String getCanonicalPath​(File file)
        Get canoncial path of file
        Parameters:
        file - File
        Returns:
        Canonical path
      • ensureFileExists

        public static File ensureFileExists​(File file)
        Ensure that file exists.
        Parameters:
        file - File
        Returns:
        File
      • ensureDirExistsAutocreate

        public static File ensureDirExistsAutocreate​(File dir)
        Ensure that directory exists and create it if not.
        Parameters:
        dir - Directory
        Returns:
        Directory
      • matchesExtension

        public static boolean matchesExtension​(String fileExtension,
                                               String extension)
        Checks file extension
        Parameters:
        fileExtension - File extension of file to check
        extension - Expected file extension
        Returns:
        true if file extension matches
      • matchesExtension

        public static boolean matchesExtension​(File file,
                                               String extension)
        Checks file extension
        Parameters:
        file - File to check
        extension - Expected file extension
        Returns:
        true if file extension matches
      • matchesExtension

        public static boolean matchesExtension​(FileContext fileContext,
                                               String extension)
        Checks file extension
        Parameters:
        fileContext - File context to check
        extension - Expected file extension
        Returns:
        true if file extension matches
      • getTemplatePath

        public static String getTemplatePath​(Role role,
                                             RoleFile roleFile)
        Get template path for a role file.
        Parameters:
        role - Role
        roleFile - Role file
        Returns:
        Path or null if not defined
      • getFileInfo

        public static String getFileInfo​(NodeRole nodeRole,
                                         RoleFile roleFile)
        Generates information to identify a file in a role definition by its file name or URL.
        Parameters:
        nodeRole - Node role
        roleFile - Role file
        Returns:
        Info string for role and file
      • getFileInfo

        public static String getFileInfo​(String roleName,
                                         RoleFile roleFile)
        Generates information to identify a file in a role definition by its file name or URL.
        Parameters:
        roleName - Role name
        roleFile - Role file
        Returns:
        Info string for role and file