Here you can find the source of getRelativeFileName(String filePath, String directoryPath)
private static String getRelativeFileName(String filePath, String directoryPath)
//package com.java2s; /*/*from ww w. j a va2 s . co m*/ * This software is distributed under the terms of the FSF * Gnu Lesser General Public License (see lgpl.txt). * * This program is distributed WITHOUT ANY WARRANTY. See the * GNU General Public License for more details. */ import java.io.File; public class Main { private static String getRelativeFileName(String filePath, String directoryPath) { String relativeFileName = filePath; if (directoryPath != null) { relativeFileName = filePath.substring(directoryPath.length()); if (relativeFileName.startsWith(File.separator)) relativeFileName = relativeFileName.substring(1); } return relativeFileName; } }