Class FileUtils
java.lang.Object
org.apache.logging.log4j.core.util.FileUtils
File utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
defineFilePosixAttributeView
(Path path, Set<PosixFilePermission> filePermissions, String fileOwner, String fileGroup) Define file POSIX attribute view on a path/file.static File
fileFromUri
(URI uri) Tries to convert the specified URI to a file object.static String
getFileExtension
(File file) static boolean
static boolean
Check if POSIX file attribute view is supported on the default FileSystem.static void
makeParentDirs
(File file) Creates the parent directories for the given File.static void
Asserts that the given directory exists and creates it if necessary.
-
Method Details
-
fileFromUri
Tries to convert the specified URI to a file object. If this fails, null is returned.- Parameters:
uri
- the URI- Returns:
- the resulting file object
-
isFile
-
getFileExtension
-
mkdir
Asserts that the given directory exists and creates it if necessary.- Parameters:
dir
- the directory that shall existcreateDirectoryIfNotExisting
- specifies if the directory shall be created if it does not exist.- Throws:
IOException
- thrown if the directory could not be created.
-
makeParentDirs
Creates the parent directories for the given File.- Parameters:
file
- For which parent directory is to be created.- Throws:
IOException
- Thrown if the directory could not be created.
-
defineFilePosixAttributeView
public static void defineFilePosixAttributeView(Path path, Set<PosixFilePermission> filePermissions, String fileOwner, String fileGroup) throws IOException Define file POSIX attribute view on a path/file.- Parameters:
path
- Target pathfilePermissions
- Permissions to applyfileOwner
- File ownerfileGroup
- File group- Throws:
IOException
- If IO error during definition of file attribute view
-
isFilePosixAttributeViewSupported
public static boolean isFilePosixAttributeViewSupported()Check if POSIX file attribute view is supported on the default FileSystem.- Returns:
- true if POSIX file attribute view supported, false otherwise
-