Class FileUtils
- java.lang.Object
-
- org.apache.logging.log4j.core.util.FileUtils
-
public final class FileUtils extends java.lang.ObjectFile utilities.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringJBOSS_FILEprivate static LoggerLOGGERprivate static java.lang.StringPROTOCOL_FILEConstant for the file URL protocol.
-
Constructor Summary
Constructors Modifier Constructor Description privateFileUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voiddefineFilePosixAttributeView(java.nio.file.Path path, java.util.Set<java.nio.file.attribute.PosixFilePermission> filePermissions, java.lang.String fileOwner, java.lang.String fileGroup)Define file POSIX attribute view on a path/file.static java.io.FilefileFromUri(java.net.URI uri)Tries to convert the specified URI to a file object.static java.lang.StringgetFileExtension(java.io.File file)static booleanisFile(java.net.URL url)static booleanisFilePosixAttributeViewSupported()Check if POSIX file attribute view is supported on the default FileSystem.static voidmakeParentDirs(java.io.File file)Creates the parent directories for the given File.static voidmkdir(java.io.File dir, boolean createDirectoryIfNotExisting)Asserts that the given directory exists and creates it if necessary.
-
-
-
Field Detail
-
PROTOCOL_FILE
private static final java.lang.String PROTOCOL_FILE
Constant for the file URL protocol.- See Also:
- Constant Field Values
-
JBOSS_FILE
private static final java.lang.String JBOSS_FILE
- See Also:
- Constant Field Values
-
LOGGER
private static final Logger LOGGER
-
-
Method Detail
-
fileFromUri
public static java.io.File fileFromUri(java.net.URI uri)
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
public static boolean isFile(java.net.URL url)
-
getFileExtension
public static java.lang.String getFileExtension(java.io.File file)
-
mkdir
public static void mkdir(java.io.File dir, boolean createDirectoryIfNotExisting) throws java.io.IOExceptionAsserts 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:
java.io.IOException- thrown if the directory could not be created.
-
makeParentDirs
public static void makeParentDirs(java.io.File file) throws java.io.IOExceptionCreates the parent directories for the given File.- Parameters:
file-- Throws:
java.io.IOException
-
defineFilePosixAttributeView
public static void defineFilePosixAttributeView(java.nio.file.Path path, java.util.Set<java.nio.file.attribute.PosixFilePermission> filePermissions, java.lang.String fileOwner, java.lang.String fileGroup) throws java.io.IOExceptionDefine file POSIX attribute view on a path/file.- Parameters:
path- Target pathfilePermissions- Permissions to applyfileOwner- File ownerfileGroup- File group- Throws:
java.io.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
-
-