Here you can find the source of getRelativePath(@Nullable File projectFile, @Nullable File rootFile)
@Nullable public static String getRelativePath(@Nullable File projectFile, @Nullable File rootFile)
//package com.java2s; // The contents of this file are subject to the Mozilla Public License import javax.annotation.Nullable; import java.io.File; public class Main { @Nullable public static String getRelativePath(@Nullable File projectFile, @Nullable File rootFile) { String returnPath = null; if (projectFile != null && rootFile != null) { returnPath = getRelativePath(projectFile.getAbsolutePath(), rootFile.getAbsolutePath()); }/*from ww w . j a v a 2 s . com*/ return returnPath; } @Nullable public static String getRelativePath( @Nullable String projectFileString, @Nullable File projectRootFile) { String returnPath = null; if (projectFileString != null && projectRootFile != null) { returnPath = getRelativePath(projectFileString, projectRootFile.getAbsolutePath()); } return returnPath; } @Nullable public static String getRelativePath(@Nullable File projectFile, @Nullable String projectRoot) { String returnPath = null; if (projectFile != null && projectRoot != null) { returnPath = getRelativePath(projectFile.getAbsolutePath(), projectRoot); } return returnPath; } @Nullable public static String getRelativePath(@Nullable String string, @Nullable String projectRoot) { String returnPath = null; if (string != null && projectRoot != null && string.startsWith(projectRoot)) { returnPath = string.substring(projectRoot.length()).replace( '\\', '/'); } return returnPath; } }