Java Path Relative Get getRelativePath(final File baseDirectory, final File f)

Here you can find the source of getRelativePath(final File baseDirectory, final File f)

Description

get Relative Path

License

Open Source License

Declaration

public static String getRelativePath(final File baseDirectory, final File f) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013, 2014, 2015 QPark Consulting S.a r.l. This program and the
 * accompanying materials are made available under the terms of the Eclipse
 * Public License v1.0. The Eclipse Public License is available at
 * http://www.eclipse.org/legal/epl-v10.html.
 ******************************************************************************/

import java.io.File;

public class Main {
    public static String getRelativePath(final File baseDirectory, final File f) {
        String s = f.getAbsolutePath();
        String base = baseDirectory.getAbsolutePath();
        if (s.startsWith(base)) {
            s = s.substring(base.length());
        }/* www. j a  v  a  2  s.c  om*/
        return s;
    }
}

Related

  1. getRelativePath(File target, File base)
  2. getRelativePath(File target, File relativeTo)
  3. getRelativePath(File wd, File file)
  4. getRelativePath(final File base, final File child)
  5. getRelativePath(final File base, final File name)
  6. getRelativePath(final File basePathFile, final File pathFile)
  7. getRelativePath(final File file, final File folder)
  8. getRelativePath(final File from, final File to)
  9. getRelativePath(final File fromFile, final File toFile)