List of utility methods to do Relative Path Get
String | relativize(String path) relativize String[] split = path.split(Pattern.quote(File.separator)); StringBuilder out = new StringBuilder(); int skip = 0; int len = split.length - 1; for (int i = len; i >= 0; i--) { if (skip > 0) skip--; else { ... |
String | relativize(String path) Relativize the given path. for (int i = 0; i < path.length(); i++) { if (path.charAt(i) != '/' && path.charAt(i) != File.separatorChar) { return i == 0 ? path : path.substring(i); return ""; |
String | relativize(String path, String base) Returns the path relative to the base. return new File(base).toURI().relativize(new File(path).toURI()).getPath(); |
String | relativizePath(File from, File to) Takes Two Path's and Relativizes One to the Other. return relativizePath(from.getAbsolutePath(), to.getAbsolutePath());
|
File | relativizePath(final File path, final File base) Relativize a path from a base path. if (path == null) { throw new NullPointerException("The path is null"); if (base == null) { return path; final File absPath = path.getAbsoluteFile(); final File absBase = base.getAbsoluteFile(); ... |
String | relativizePath(String parent, String child) relativize Path if (parent != null && child != null) { if (parent.equals(child)) { return ""; if (!parent.endsWith(File.separator)) { parent += File.separator; if (child.startsWith(parent)) { ... |
String | relativizePathSegments(String[] srcSegments, String[] destSegments) Computes a string containing the relative path from the directory or file represented by the source segments to the directory or file represented by the destination segments. int srcIndex = srcSegments.length - 1; int destIndex = destSegments.length - 1; StringBuffer relativePath = new StringBuffer(); while (srcIndex >= 0 && destIndex >= 0 && srcSegments[srcIndex].equals(destSegments[destIndex])) { srcIndex--; destIndex--; for (; srcIndex >= 0; srcIndex--) { ... |