Class FileUtils
java.lang.Object
org.carrot2.util.FileUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringcanonicalize(String path, String separator) Removes useless segments in relative paths, e.g. replaces..static StringchangeRoot(String file, String oldRoot, String newRoot) Changes the root directory of a file.static voiddeleteThrowingExceptions(File... files) Attempts to delete the provided files and throws anIOExceptionin caseFile.delete()returnsfalsefor any of them.static FileCreates a newFilefrom the provided path and attempts to executeFile.getCanonicalFile().static booleanisFileInParent(File file, File parent) Returnstrueif file is contained in the parent directory or any parent of the parent directory.static voidmkdirsThrowingExceptions(File dirs)
-
Method Details
-
getCanonicalOrAbsoluteFile
Creates a newFilefrom the provided path and attempts to executeFile.getCanonicalFile(). In case of a failure, returns the result ofFile.getAbsoluteFile().- Parameters:
path- the path- Returns:
- the canonical or absolute file
-
changeRoot
Changes the root directory of a file. For example, file is /a/b/c/d/e and oldRoot is /a/b/c, and newRoot is /x/y, the result will be /x/y/d/e.- Parameters:
file- the fileoldRoot- the old rootnewRoot- the new root- Returns:
- the string
-
canonicalize
-
deleteThrowingExceptions
Attempts to delete the provided files and throws anIOExceptionin caseFile.delete()returnsfalsefor any of them.- Parameters:
files- the files- Throws:
IOException- Signals that an I/O exception has occurred.
-
mkdirsThrowingExceptions
- Parameters:
dirs- the dirs- Throws:
IOException- Signals that an I/O exception has occurred.
-
isFileInParent
-