Here you can find the source of getRelativePath(File baseDir, File file)
public static String getRelativePath(File baseDir, File file)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static String getRelativePath(File baseDir, File file) { String filePath = file.getAbsolutePath(); String basePath = baseDir.getAbsolutePath(); String relativePath = filePath.substring(basePath.length()); if (relativePath.charAt(0) == File.separatorChar) { relativePath = relativePath.substring(1); }/*from ww w . j a v a 2s.c o m*/ return relativePath; } }