Here you can find the source of relativePath(final String inputPath, final File file)
public static String relativePath(final String inputPath, final File file)
//package com.java2s; //License from project: LGPL import java.io.*; public class Main { public static String relativePath(final String inputPath, final File file) { String filePath = normalizePath(file.getAbsolutePath()); String relativePath = filePath; if (filePath.contains("/")) { relativePath = filePath.substring(0, filePath.lastIndexOf("/")); }// ww w.j av a 2 s.c o m relativePath = relativePath.substring(normalizePath(inputPath).length()); return relativePath; } public static String normalizePath(final String in) { String out = in; if (in.endsWith("/")) { out = in.substring(0, in.length() - 1); } return out.replace("\\", "/"); } }