public final class FileUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
changeLocalFilePermission(String filePath,
String perms)
Changes local file's permission.
|
static void |
changeLocalFileToFullPermission(String filePath)
Changes local file's permission to be 777.
|
static void |
createBlockPath(String path)
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 void |
createStorageDirPath(String path)
Creates the storage directory path, including any necessary but nonexistent parent directories.
|
static void |
delete(String path)
Deletes the file or directory.
|
static boolean |
exists(String path)
Checks if a path exists.
|
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.
|
public static void changeLocalFilePermission(String filePath, String perms) throws IOException
filePath - that will change permissionperms - the permission, e.g. "775"IOException - when fails to change permissionpublic static void changeLocalFileToFullPermission(String filePath) throws IOException
filePath - that will change permissionIOException - when fails to change file's permission to 777public static void setLocalDirStickyBit(String dir)
dir - absolute dir path to set the sticky bitpublic static void createBlockPath(String path) throws IOException
path - The path of the block.IOException - when fails to create block path and parent directories with appropriate
permissions.public static void move(String srcPath, String dstPath) throws IOException
File.renameTo(java.io.File) may not work.
Current implementation uses Files.move(File, File), may change if
there is a better solution.srcPath - pathname string of source filedstPath - pathname string of destination fileIOException - when fails to movepublic static void delete(String path) throws IOException
File.delete(), may change if there is a better
solution.path - pathname string of file or directoryIOException - when fails to deletepublic static void createStorageDirPath(String path) throws IOException
path - storage directory path to createIOException - when fails to create storage directory pathpublic static void createFile(String filePath) throws IOException
filePath - pathname string of the file to createIOException - if an I/O error occurred or file already existspublic static void createDir(String path) throws IOException
path - path of the directory to createIOException - if an I/O error occurred or directory already existspublic static boolean exists(String path)
path - the given pathCopyright © 2015. All Rights Reserved.