Here you can find the source of getRelativePath(File dir, File child)
public static String getRelativePath(File dir, File child)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { /**/* w w w . j a v a 2 s. c om*/ * Get relative path from two absolute paths. * * @return */ public static String getRelativePath(File dir, File child) { return dir.getAbsoluteFile().toURI().relativize(child.getAbsoluteFile().toURI()).getPath(); } }