Here you can find the source of getRelativePath(File file, File root)
Parameter | Description |
---|---|
file | a parameter |
root | a parameter |
public static String getRelativePath(File file, File root)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { /**// ww w. j a v a 2 s. c o m * Strips off the part of the path before the start of the root file. If the root is c:\temp\foo * and the file is c:\temp\foo\folder\file.txt this will return folder\ * * @param file * @param root * @return */ public static String getRelativePath(File file, File root) { int rootLength = root.getAbsolutePath().length(); String absolutePath = file.getAbsolutePath(); String relativePath = absolutePath.substring(rootLength + 1); return relativePath; } }