List of utility methods to do Path Relative Get
String | getRelativePath(String fileName, String projFile) Get relative path of the file using project file path String RelativePath = ""; File aFile = new File(fileName); File pFile = new File(projFile); fileName = aFile.getCanonicalPath(); String layerPathRoot = getPathRoot(aFile); String projPathRoot = getPathRoot(pFile); if (!layerPathRoot.equalsIgnoreCase(projPathRoot)) { RelativePath = fileName; ... |
String | getRelativePath(String filePath, String basePath) get Relative Path File target = new File(filePath); File base = new File(basePath); StringBuilder result = new StringBuilder(); try { String[] baseComponents = base.getCanonicalPath().split(Pattern.quote(File.separator)); String[] targetComponents = target.getCanonicalPath().split(Pattern.quote(File.separator)); int index = 0; for (; index < targetComponents.length && index < baseComponents.length; ++index) { ... |
String | getRelativePath(String from, String to) Returns the relative path from one file to the other. if (!(new File(to)).isAbsolute()) return to; File fromFile = new File(from); if (fromFile.exists() && !fromFile.isDirectory()) fromFile = fromFile.getParentFile(); try { from = fromFile.getCanonicalPath(); to = new File(to).getCanonicalPath(); ... |
String | getRelativePath(String parent, String child) get Relative Path parent = parent.replace(File.separatorChar, '/'); child = child.replace(File.separatorChar, '/'); String relativePath = getPathAsChild(parent, child); return relativePath == null ? "" : relativePath; |
String | getRelativePath(String path, String base) get relative path according the give path and base if (path == null || base == null) return null; if (System.getProperty("os.name").toLowerCase().startsWith("windows")) { path = path.toLowerCase(); base = base.toLowerCase(); if (path.lastIndexOf(base) < 0) { int index = path.lastIndexOf("/"); ... |
String | getRelativePath(String root, String path) get Relative Path if (root.equals(path)) { return "." + File.separatorChar; } else { return path.replace(root, "."); |
String | getRelativePath(String rootpath, String path) get Relative Path String[] r = tokenizePath(rootpath); String[] p = tokenizePath(path); if (r.length == 0 || p.length == 0 || !r[0].equalsIgnoreCase(p[0])) return null; int i = 0; while (i < r.length && i < p.length && r[i].equalsIgnoreCase(p[i])) ++i; StringBuffer sb = new StringBuffer(); ... |
String | getRelativePath(String source, String target) get Relative Path if (source == null || target == null) { return target; File sourceFile = new File(source); if (!sourceFile.exists()) { return target; File targetFile = new File(target); ... |
String | getRelativePath(String target, String base) Returns the path of one file relative to another. String split = Pattern.quote(File.separator); String[] baseSegments = base.split(split); String[] targetSegments = target.split(split); StringBuilder result = new StringBuilder(); int index = 0; for (; index < targetSegments.length && index < baseSegments.length; ++index) { if (!targetSegments[index].equals(baseSegments[index])) break; ... |
String | getRelativePath(String targetPath, String basePath, String pathSeparator) get Relative Path String[] base = basePath.split(Pattern.quote(pathSeparator)); String[] target = targetPath.split(Pattern.quote(pathSeparator)); StringBuilder common = new StringBuilder(); int commonIndex = 0; while (commonIndex < target.length && commonIndex < base.length && target[commonIndex].equals(base[commonIndex])) { common.append(target[commonIndex]).append(pathSeparator); commonIndex++; ... |