Here you can find the source of getRelativePath(final File base, final File child)
public static String getRelativePath(final File base, final File child)
//package com.java2s; //License from project: LGPL import java.io.File; public class Main { public static String getRelativePath(final File base, final File child) { if (base == null || child == null) { throw new IllegalArgumentException("Cannot be null."); }// ww w . j a v a 2 s . c om return base.toURI().relativize(child.toURI()).getPath(); } }