Package org.carrot2.util
Class PathUtils
java.lang.Object
org.carrot2.util.PathUtils
This class defines utilities methods helping to determine path-related information such as relative paths.
The original code comes from org.codehaus.plexus.util.PathTool.
- Author:
- Ibrahim Chaehoi, Pete Kazmier, Vincent Massol, Vincent Siveton
-
Method Summary
Modifier and TypeMethodDescriptionstatic final String
getRelativeFilePath
(String oldPath, String newPath) This method can calculate the relative path between two pathes on a file system.
-
Method Details
-
getRelativeFilePath
This method can calculate the relative path between two pathes on a file system.PathUtils.getRelativeFilePath( null, null ) = "" PathUtils.getRelativeFilePath( null, "/usr/local/java/bin" ) = "" PathUtils.getRelativeFilePath( "/usr/local", null ) = "" PathUtils.getRelativeFilePath( "/usr/local", "/usr/local/java/bin" ) = "java/bin" PathUtils.getRelativeFilePath( "/usr/local", "/usr/local/java/bin/" ) = "java/bin" PathUtils.getRelativeFilePath( "/usr/local/java/bin", "/usr/local/" ) = "../.." PathUtils.getRelativeFilePath( "/usr/local/", "/usr/local/java/bin/java.sh" ) = "java/bin/java.sh" PathUtils.getRelativeFilePath( "/usr/local/java/bin/java.sh", "/usr/local/" ) = "../../.." PathUtils.getRelativeFilePath( "/usr/local/", "/bin" ) = "../../bin" PathUtils.getRelativeFilePath( "/bin", "/usr/local/" ) = "../usr/local"
Note: On Windows based system, the/
character should be replaced by\
character.- Parameters:
oldPath
- the old pathnewPath
- the new path- Returns:
- a relative file path from
oldPath
.
-