Answers for "get java path in java"

3

get file path java

File file = new File("yourfileName");
String path = file.getAbsolutePath();
Posted by: Guest on February-24-2020
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