Here you can find the source of getRelativePath(String basePath, String path)
Parameter | Description |
---|---|
basePath | a parameter |
path | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static String getRelativePath(String basePath, String path) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; public class Main { /**// w w w . j a va2s .c o m * Get the relative path from the canoical basepath and path. * * @param basePath * @param path * @return * @throws IOException */ public static String getRelativePath(String basePath, String path) throws IOException { if (basePath == null || path == null || basePath.equalsIgnoreCase(path)) return ""; else if (path.startsWith(basePath)) { String relPath = path.substring(basePath.length(), path.length()); return "." + relPath; } return ""; } }