Here you can find the source of getRelativePath(File parent, File child)
public static String getRelativePath(File parent, File child)
//package com.java2s; //License from project: LGPL import java.io.File; public class Main { public static String getRelativePath(File parent, File child) { if (parent.isFile() || !child.getPath().startsWith(parent.getPath())) { return null; }/*from w w w .ja v a 2 s . c om*/ return child.getPath().substring(parent.getPath().length() + 1); } }