Here you can find the source of getRelativePath(File file, File directory)
public static String getRelativePath(File file, File directory)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static String getRelativePath(File file, File directory) { String relativePath = file.getPath().substring((int) directory.getPath().length()); if (relativePath.startsWith("/") || relativePath.startsWith("\\")) relativePath = relativePath.substring(1); return relativePath; }//from w w w .java2s. c o m }