Here you can find the source of relativePath(String input, String mainurl)
Parameter | Description |
---|---|
input | a parameter |
mainurl | a parameter |
public static String relativePath(String input, String mainurl)
//package com.java2s; //License from project: Open Source License import java.nio.file.Path; import java.nio.file.Paths; public class Main { /**/*from www . j a v a 2 s. com*/ * Compute sub directory of given input, relative to main module. * @param input * @param mainurl * @return a relative path */ public static String relativePath(String input, String mainurl) { Path inputPath = Paths.get(input); Path rootPath = Paths.get(mainurl); Path relativize = rootPath.getParent().relativize(inputPath.getParent()); return relativize.toString(); } }