Java Path Relative nio getRelativePath(String file, String directory)

Here you can find the source of getRelativePath(String file, String directory)

Description

get Relative Path

License

Open Source License

Declaration

public static String getRelativePath(String file, String directory) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.nio.file.*;

public class Main {
    public static String getRelativePath(String file, String directory) {
        Path pathAbsolute = Paths.get(file);
        Path pathBase = Paths.get(directory);
        Path pathRelative = pathBase.relativize(pathAbsolute);
        return pathRelative.toString();
    }/*from   w  w  w .  j ava 2  s . c o m*/
}

Related

  1. getRelativePath(File basePath, File path)
  2. getRelativePath(File root, File f)
  3. getRelativePath(final File file, final File baseDir)
  4. getRelativePath(Path file, Path baseDir)
  5. getRelativePath(Path rootPath, Path path)
  6. getRelativePath(String fullPath, String homeFolderPath)
  7. getRelativePath(String relativePathFile)
  8. getSourceFileRelativePath(Class declaringClass)
  9. isRelativePath(Path baseDir, Path file)