Answers for "java get relative pathh"

3

java get relative path

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"
Posted by: Guest on September-13-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language