Here you can find the source of getRelativePath(File root, File file)
Parameter | Description |
---|---|
root | the root path to get relative from. |
file | the file to get the relative path of. |
public static String getRelativePath(File root, File file)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { /**//from www. ja va2s. co m * gets the relative path of a file. * @param root the root path to get relative from. * @param file the file to get the relative path of. * @return the relative path of the file. */ public static String getRelativePath(File root, File file) { String rel = file.getAbsolutePath().substring( root.getAbsolutePath().length() + 1); rel = rel.replaceAll("\\\\", "/"); return rel; } }