Java Path Relative Get getRelativePath(File baseDir, File file)

Here you can find the source of getRelativePath(File baseDir, File file)

Description

get Relative Path

License

Open Source License

Declaration

public static String getRelativePath(File baseDir, File file) 

Method Source Code


//package com.java2s;
import java.io.File;

public class Main {
    public static String getRelativePath(File baseDir, File file) {
        if (baseDir.equals(file))
            return "";
        if (baseDir.getParentFile() == null)
            return file.getAbsolutePath().substring(baseDir.getAbsolutePath().length());
        return file.getAbsolutePath().substring(baseDir.getAbsolutePath().length() + 1);
    }//from w w w.j  a va 2s .  c  o m
}

Related

  1. getRelativePath(File base, File name)
  2. getRelativePath(File base, File name)
  3. getRelativePath(File base, File path)
  4. getRelativePath(File base, File path)
  5. getRelativePath(File base, File target)
  6. getRelativePath(File baseDir, File file)
  7. getRelativePath(File baseDir, File file)
  8. getRelativePath(File baseDir, File file)
  9. getRelativePath(File baseDir, File subFile, String seperator)