Java Path Relative Get getRelativePath(File folderContainingFile, File fileInFolder)

Here you can find the source of getRelativePath(File folderContainingFile, File fileInFolder)

Description

get Relative Path

License

Apache License

Declaration

public static String getRelativePath(File folderContainingFile, File fileInFolder) throws IOException 

Method Source Code

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

import java.io.File;
import java.io.IOException;

public class Main {
    public static String getRelativePath(File folderContainingFile, File fileInFolder) throws IOException {
        String filePath = fileInFolder.getCanonicalPath();
        String folderPath = folderContainingFile.getCanonicalPath();
        return new File(folderPath).toURI().relativize(new File(filePath).toURI()).getPath();
    }//  w  w  w  . jav a 2  s  . c om
}

Related

  1. getRelativePath(File file, File root)
  2. getRelativePath(File file, File root)
  3. getRelativePath(File file, File srcDir)
  4. getRelativePath(File file, String xmlDirectoryPath)
  5. getRelativePath(File fileOrFolder, File baseFolder)
  6. getRelativePath(File fromDir, File toFile)
  7. getRelativePath(File fromFile, File toFile)
  8. getRelativePath(File fromFile, File toFile)
  9. getRelativePath(File fromFile, File toFile)