Package com.android.utils
Class PathUtils
- java.lang.Object
-
- com.android.utils.PathUtils
-
public final class PathUtils extends java.lang.ObjectUtility methods forPath.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddRemovePathHook(java.nio.file.Path path)Adds a hook to the shutdown event of the JVM which will delete all files and directories at the given path (inclusive) when the JVM exits.static java.nio.file.PathcreateTmpDirToRemoveOnShutdown(java.lang.String prefix)static java.nio.file.PathcreateTmpToRemoveOnShutdown(java.lang.String prefix)static voiddeleteRecursivelyIfExists(java.nio.file.Path path)Deletes a file or a directory if it exists.static java.util.List<java.nio.file.Path>getClassPathItems(java.lang.String classPath)static java.lang.StringtoSystemIndependentPath(java.nio.file.Path path)Returns a system-independent path.
-
-
-
Method Detail
-
deleteRecursivelyIfExists
public static void deleteRecursivelyIfExists(@NonNull java.nio.file.Path path) throws java.io.IOExceptionDeletes a file or a directory if it exists. If the directory is not empty, its contents will be deleted recursively. Symbolic links to files or directories will be removed, but the files or directories they link will not be altered. See https://issuetracker.google.com/71843178- Parameters:
path- the file or directory to delete. The file/directory may not exist; if the directory exists, it may be non-empty.- Throws:
java.io.IOException
-
toSystemIndependentPath
@NonNull public static java.lang.String toSystemIndependentPath(@NonNull java.nio.file.Path path)Returns a system-independent path.
-
createTmpToRemoveOnShutdown
@NonNull public static java.nio.file.Path createTmpToRemoveOnShutdown(@NonNull java.lang.String prefix) throws java.io.IOException- Throws:
java.io.IOException
-
createTmpDirToRemoveOnShutdown
@NonNull public static java.nio.file.Path createTmpDirToRemoveOnShutdown(@NonNull java.lang.String prefix) throws java.io.IOException- Throws:
java.io.IOException
-
getClassPathItems
@NonNull public static java.util.List<java.nio.file.Path> getClassPathItems(@NonNull java.lang.String classPath)
-
addRemovePathHook
public static void addRemovePathHook(@NonNull java.nio.file.Path path)Adds a hook to the shutdown event of the JVM which will delete all files and directories at the given path (inclusive) when the JVM exits.- Parameters:
path- the path to delete
-
-