开发者

java calculate pathname difference [duplicate]

开发者 https://www.devze.com 2023-02-17 22:36 出处:网络
This question already has answers here: How to construct a relative path in Java from two absolute paths (or URLs)?
This question already has answers here: How to construct a relative path in Java from two absolute paths (or URLs)? (23 answers) Closed 6 years ago.

开发者_运维知识库Is there an open source library that, given ...

/a/b/c
/a/b/c/d/e

would return ../..

or for that matter given

/a/b/c/d
/a/b/c/e

would return ../d

?


If you don't mind passing by converting your Strings into URI then this latter one has the method relativize which should do exactly what you want, take a look here.

0

精彩评论

暂无评论...
验证码 换一张
取 消