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

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

Description

get Relative Path

License

Apache License

Declaration

public static String getRelativePath(File file, File folder) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {

    public static String getRelativePath(File file, File folder) {

        String filePath = file.getAbsolutePath();
        String folderPath = folder.getAbsolutePath();

        if (filePath.startsWith(folderPath)) {
            return filePath.substring(folderPath.length() + 1);
        } else {//from   w  w w. j ava 2  s . com
            return null;
        }
    }
}

Related

  1. getRelativePath(File file)
  2. getRelativePath(File file, File basedir)
  3. getRelativePath(File file, File baseDir)
  4. getRelativePath(File file, File baseDirectory)
  5. getRelativePath(File file, File directory)
  6. getRelativePath(File file, File root)
  7. getRelativePath(File file, File root)
  8. getRelativePath(File file, File srcDir)
  9. getRelativePath(File file, String xmlDirectoryPath)