Get root from a Path Object in Java
Description
The following code shows how to get root from a Path Object.
Example
import java.nio.file.FileSystems;
import java.nio.file.Path;
// w ww .j av a2 s. c o m
public class Main {
public static void main(String[] args) {
Path path = FileSystems.getDefault().getPath("/home/docs/status.txt");
System.out.printf("getRoot: %s\n", path.getRoot());
}
}
The code above generates the following result.