Here you can find the source of getRelativePath(File file, File folder)
public static String getRelativePath(File file, File folder)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static String getRelativePath(File file, File folder) { String filePath = file.getAbsolutePath(); String folderPath = folder.getAbsolutePath(); if (filePath.startsWith(folderPath)) { return filePath.substring(folderPath.length() + 1); } else {//from w w w. j ava 2 s . com return null; } } }