@ThreadSafe public final class FileUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
changeLocalFileGroup(String path,
String group)
Changes the local file's group.
|
static void |
changeLocalFilePermission(String filePath,
String perms)
Changes local file's permission.
|
static void |
changeLocalFileToFullPermission(String filePath)
Changes local file's permission to be "rwxrwxrwx".
|
static void |
changeLocalFileUser(String path,
String user)
Changes the local file's user.
|
static void |
createBlockPath(String path,
String workerDataFolderPermissions)
Creates the local block path and all the parent directories.
|
static void |
createDir(String path)
Creates an empty directory and its intermediate directories if necessary.
|
static void |
createFile(String filePath)
Creates an empty file and its intermediate directories if necessary.
|
static boolean |
createStorageDirPath(String path,
String workerDataFolderPermissions)
Creates the storage directory path, including any necessary but nonexistent parent directories.
|
static void |
delete(String path)
Deletes the file or directory.
|
static void |
deletePathRecursively(String path)
Deletes a file or a directory, recursively if it is a directory.
|
static boolean |
exists(String path)
Checks if a path exists.
|
static String |
getLocalFileGroup(String filePath)
Gets local file's group.
|
static short |
getLocalFileMode(String filePath)
Gets local file's permission mode.
|
static String |
getLocalFileOwner(String filePath)
Gets local file's owner.
|
static boolean |
isStorageDirAccessible(String path)
Checks if a storage directory path is accessible.
|
static void |
move(String srcPath,
String dstPath)
Moves file from one place to another, can across storage devices (e.g., from memory to SSD)
when
File.renameTo(java.io.File) may not work. |
static void |
setLocalDirStickyBit(String dir)
Sticky bit can be set primarily on directories in UNIX / Linux.
|
static short |
translatePosixPermissionToMode(Set<PosixFilePermission> permission)
Translate posix file permissions to short mode.
|
public static void changeLocalFileGroup(String path, String group) throws IOException
path
- that will change ownergroup
- the new groupIOException
public static void changeLocalFilePermission(String filePath, String perms) throws IOException
filePath
- that will change permissionperms
- the permission, e.g. "rwxr--r--"IOException
public static void changeLocalFileToFullPermission(String filePath) throws IOException
filePath
- that will change permissionIOException
public static String getLocalFileOwner(String filePath) throws IOException
filePath
- the file pathIOException
public static String getLocalFileGroup(String filePath) throws IOException
filePath
- the file pathIOException
public static short getLocalFileMode(String filePath) throws IOException
filePath
- the file pathIOException
public static short translatePosixPermissionToMode(Set<PosixFilePermission> permission)
permission
- posix file permissionpublic static void changeLocalFileUser(String path, String user) throws IOException
path
- that will change owneruser
- the new userIOException
public static void setLocalDirStickyBit(String dir)
dir
- absolute dir path to set the sticky bitpublic static void createBlockPath(String path, String workerDataFolderPermissions) throws IOException
path
- the path of the blockworkerDataFolderPermissions
- The permissions to set on the worker's data folderIOException
public static void move(String srcPath, String dstPath) throws IOException
File.renameTo(java.io.File)
may not work.srcPath
- pathname string of source filedstPath
- pathname string of destination fileIOException
public static void delete(String path) throws IOException
path
- pathname string of file or directoryIOException
public static void deletePathRecursively(String path) throws IOException
path
- pathname to be deletedIOException
public static boolean createStorageDirPath(String path, String workerDataFolderPermissions) throws IOException
path
- storage directory path to createworkerDataFolderPermissions
- the permissions to set for the worker's data folderIOException
public static void createFile(String filePath) throws IOException
filePath
- pathname string of the file to createIOException
public static void createDir(String path) throws IOException
path
- path of the directory to createIOException
public static boolean exists(String path)
path
- the given pathpublic static boolean isStorageDirAccessible(String path)
path
- the given pathCopyright © 2023. All Rights Reserved.