- java.lang.Object
-
- de.carne.nio.file.FileUtil
-
public final class FileUtil extends java.lang.ObjectUtility class providing file related functions.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleandelete(java.nio.file.Path fileOrDirectory)Deletes a file or directory (including any included file).static @NonNull java.lang.String[]splitPath(java.lang.String path)Splits a path into it's three parts directory, name and extension.static java.nio.file.PathtmpDir()Gets the temporary directory path.static java.nio.file.Pathtouch(java.nio.file.Path file)Sets the submitted file last modified time to the current time.static java.nio.file.PathuserHomeDir()Gets the user's home directory path.static java.nio.file.PathworkingDir()Gets the current working directory path.
-
-
-
Method Detail
-
tmpDir
public static java.nio.file.Path tmpDir()
Gets the temporary directory path.- Returns:
- the temporary directory path.
-
userHomeDir
public static java.nio.file.Path userHomeDir()
Gets the user's home directory path.- Returns:
- the user's home directory path.
-
workingDir
public static java.nio.file.Path workingDir()
Gets the current working directory path.- Returns:
- the current working directory path.
-
touch
public static java.nio.file.Path touch(java.nio.file.Path file) throws java.io.IOExceptionSets the submitted file last modified time to the current time.If the file does not yet exist, it will be created.
- Parameters:
file- the file to touch.- Returns:
- the submitted file.
- Throws:
java.io.IOException- if an I/O error occurs.
-
delete
public static boolean delete(java.nio.file.Path fileOrDirectory) throws java.io.IOExceptionDeletes a file or directory (including any included file).- Parameters:
fileOrDirectory- the file or director to delete.- Returns:
trueif the file or directory was deleted.falseif the file or directory does not exist.- Throws:
java.io.IOException- if an I/O error occurs during deletion.
-
splitPath
public static @NonNull java.lang.String[] splitPath(java.lang.String path)
Splits a path into it's three parts directory, name and extension.For missing parts the empty string is returned.
- Parameters:
path- the path to split.- Returns:
- the three path parts.
-
-