List of utility methods to do Path Relative Get
String | getRelativePath(String targetPath, String basePath, String pathSeparator) get Relative Path File f = new File(targetPath); boolean isDir = f.isDirectory(); String[] base = basePath.split(Pattern.quote(pathSeparator), -1); String[] target = targetPath.split(Pattern.quote(pathSeparator), 0); String common = ""; int commonIndex = 0; for (int i = 0; i < target.length && i < base.length; i++) { if (target[i].equals(base[i])) { ... |
String | getRelativePathOfZipEntry(final File fileToZip, final File base) get Relative Path Of Zip Entry String relativePathOfFile = fileToZip.getPath().substring(base.getPath().length() + 1); if (File.separatorChar != '/') { relativePathOfFile = relativePathOfFile.replace(File.separatorChar, '/'); return relativePathOfFile; |
String | getRelativePathRecursive(File file, File baseDir, String prefix) get Relative Path Recursive if (isFileInDirRecursive(file, baseDir)) { return prefix + baseDir.toURI().relativize(file.toURI()).getPath(); } else if (baseDir.getParentFile() != null) { return prefix + getRelativePathRecursive(file, baseDir.getParentFile(), "../"); } else { return file.toURI().toString(); |
String | getRelativePathToBase(File path, File basePath) Returns the relative path of a path from a base path. try { String dir = path.toURL().toExternalForm(); String baseDir = basePath.toURL().toExternalForm(); StringBuffer result = new StringBuffer(); if (dir.indexOf(baseDir) == 0) { String delta = dir.substring(baseDir.length()); for (int i = 0; i < delta.length(); i++) { if (delta.charAt(i) == '/') { ... |
String | getRelativePathToTestModule() get Relative Path To Test Module String relativePathToModule = "." + File.separator + "MainServer" + File.separator + "OurPlatformManager" + File.separator + "target" + File.separator + "TestModule-0.4-SNAPSHOT-mod.zip"; return relativePathToModule; |
String | getRelativePathToWWW(String fileName) get Relative Path To WWW return getRelativePathTo("www", fileName); |