List of utility methods to do Path Relative Get
String | getRelativePath(@Nullable File projectFile, @Nullable File rootFile) get Relative Path String returnPath = null; if (projectFile != null && rootFile != null) { returnPath = getRelativePath(projectFile.getAbsolutePath(), rootFile.getAbsolutePath()); return returnPath; |
String | getRelativePath(File a, File b, String pathSep) get Relative Path return getRelativePath(a.getAbsolutePath(), b.getAbsolutePath(), pathSep);
|
String | getRelativePath(File ancestor, File file) get Relative Path return getRelativePath(ancestor, file, "/"); |
File | getRelativePath(File base, File absoluteFile) get Relative Path checkAbsolutePath(base); checkAbsolutePath(absoluteFile); try { File res = base.toPath().relativize(absoluteFile.toPath()).toFile(); return new File('.' + File.separator + res.getPath()); } catch (Exception ignored) { String[] basePath = getPathParts(base); ... |
String | getRelativePath(File base, File file) Get relative path between two files http://stackoverflow.com/questions/204784/how-to-construct-a-relative-path-in-java-from-two-absolute-paths-or-urls return base.toURI().relativize(file.toURI()).getPath();
|
String | getRelativePath(File base, File file) returns the relative path of file to base. String filePath = file.getAbsoluteFile().getCanonicalPath(); String basePath = base.getAbsoluteFile().getCanonicalPath(); int start = filePath.indexOf(basePath); if (start != 0) throw new IOException(basePath + " not ancestor of " + filePath); return filePath.substring(basePath.length()); |
String | getRelativePath(File base, File file) get Relative Path String basePath = base.getCanonicalPath();
String filePath = file.getCanonicalPath();
return getRelativePath(basePath, filePath);
|
File | getRelativePath(File base, File file) Finds the relative path from base to file. try { String absBase = base.getCanonicalPath(); String absFile = file.getCanonicalPath(); if (absBase.equals(absFile)) { return new File(""); int divergenceCharIndex = 0; int divergenceSeperatorIndex = 0; ... |
String | getRelativePath(File base, File name) Computes the path for a file relative to a given base, or fails if the only shared directory is the root and the absolute form is better. File parent = base.getParentFile(); if (parent == null) { throw new IOException("No common directory"); String bpath = base.getCanonicalPath(); String fpath = name.getCanonicalPath(); if (fpath.startsWith(bpath)) { return fpath.substring(bpath.length() + 1); ... |
String | getRelativePath(File base, File name) Computes the path for a file relative to a given base, or fails if the only shared directory is the root and the absolute form is better. if (base != null && name != null) { File parent = base.getParentFile(); if (name.getName().length() > 0) { try { if (parent == null) { return name.getAbsolutePath(); String bpath = base.getCanonicalPath(); ... |