📜  java 获取相对路径 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:44.261000             🧑  作者: Mango

代码示例1
String path = "/var/data/stuff/xyz.dat";
String base = "/var/data";
String relative = new File(base).toURI().relativize(new File(path).toURI()).getPath();
// relative == "stuff/xyz.dat"