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

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

Description

get Relative Path

License

Open Source License

Declaration

public static String getRelativePath(File file, File directory) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    public static String getRelativePath(File file, File directory) {
        String relativePath = file.getPath().substring((int) directory.getPath().length());
        if (relativePath.startsWith("/") || relativePath.startsWith("\\"))
            relativePath = relativePath.substring(1);
        return relativePath;
    }//from   w  w w .java2s.  c o  m
}

Related

  1. getRelativePath(File f, File base)
  2. getRelativePath(File file)
  3. getRelativePath(File file, File basedir)
  4. getRelativePath(File file, File baseDir)
  5. getRelativePath(File file, File baseDirectory)
  6. getRelativePath(File file, File folder)
  7. getRelativePath(File file, File root)
  8. getRelativePath(File file, File root)
  9. getRelativePath(File file, File srcDir)