Class FileUtil
- java.lang.Object
-
- io.wcm.devops.conga.generator.util.FileUtil
-
public final class FileUtil extends Object
Utility methods for file handling.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static File
ensureDirExistsAutocreate(File dir)
Ensure that directory exists and create it if not.static File
ensureFileExists(File file)
Ensure that file exists.static String
getCanonicalPath(FileContext fileContext)
Deprecated, for removal: This API element is subject to removal in a future version.useFileContext.getCanonicalPath()
instead.static String
getCanonicalPath(File file)
Get canoncial path of filestatic String
getFileInfo(NodeRole nodeRole, RoleFile roleFile)
Generates information to identify a file in a role definition by its file name or URL.static String
getFileInfo(String roleName, RoleFile roleFile)
Generates information to identify a file in a role definition by its file name or URL.static String
getTemplatePath(Role role, RoleFile roleFile)
Get template path for a role file.static boolean
matchesExtension(FileContext fileContext, String extension)
Checks file extensionstatic boolean
matchesExtension(File file, String extension)
Checks file extensionstatic boolean
matchesExtension(String fileExtension, String extension)
Checks file extension
-
-
-
Method Detail
-
getCanonicalPath
public static String getCanonicalPath(File file)
Get canoncial path of file- Parameters:
file
- File- Returns:
- Canonical path
-
getCanonicalPath
@Deprecated(forRemoval=true) public static String getCanonicalPath(FileContext fileContext)
Deprecated, for removal: This API element is subject to removal in a future version.useFileContext.getCanonicalPath()
instead.Get canoncial path of file- Parameters:
fileContext
- File context- 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 checkextension
- 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 checkextension
- 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 checkextension
- 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
- RoleroleFile
- 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 roleroleFile
- Role file- Returns:
- Info string for role and file
-
-