Java Path Relative Get getRelativePath(File base, File file)

Here you can find the source of getRelativePath(File base, File file)

Description

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

License

Open Source License

Parameter

Parameter Description
base a parameter
file a parameter

Return

relative path

Declaration

public static String getRelativePath(File base, File file) 

Method Source Code


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

import java.io.File;

public class Main {
    /**/*from w ww. j  av  a 2s  . c o m*/
     * 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
     * @param base
     * @param file
     * @return relative path
     */
    public static String getRelativePath(File base, File file) {
        return base.toURI().relativize(file.toURI()).getPath();
    }
}

Related

  1. getRelativePath(File a, File b, String pathSep)
  2. getRelativePath(File ancestor, File file)
  3. getRelativePath(File base, File absoluteFile)
  4. getRelativePath(File base, File file)
  5. getRelativePath(File base, File file)
  6. getRelativePath(File base, File file)
  7. getRelativePath(File base, File name)
  8. getRelativePath(File base, File name)
  9. getRelativePath(File base, File path)