Here you can find the source of 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
Parameter | Description |
---|---|
base | a parameter |
file | a parameter |
public static String getRelativePath(File base, File file)
//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(); } }