Java Path Relative getRelativeFileName(String filePath, String directoryPath)

Here you can find the source of getRelativeFileName(String filePath, String directoryPath)

Description

get Relative File Name

License

LGPL

Declaration

private static String getRelativeFileName(String filePath,
            String directoryPath) 

Method Source Code

//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;
    }
}

Related

  1. getRelativeFileFromReference(String ref, File metadataFile)
  2. getRelativeFileInternal(File canonicalBaseFile, File canonicalFileToRelativize)
  3. getRelativeFilename(File base, File target)
  4. getRelativeFileName(File file, File basedir)
  5. getRelativeFileName(File target, File realativeTo)
  6. getRelativeFilePath(File absolutePath, File reference)
  7. getRelativeFilePath(String filePath, String relativePathPrefix)
  8. getRelativeLastModifiedTimeFile()
  9. getRelativeLink(File target, File base)