Java 计算相对路径

import java.nio.file.Path;
import java.nio.file.Paths;

public class temp {
    public static void main(String[] args) {
        Path pathAbsolute = Paths.get("src\Portal\Client\assets\tts\");
        Path pathBase = Paths.get("src\Portal\Client\src\component\tts\data\dataRecordingComponents");
        Path pathRelative = pathBase.relativize(pathAbsolute);
        System.out.println(pathRelative);
    }
}
原文地址:https://www.cnblogs.com/xym4869/p/13567221.html