Java Path get root path

Description

Java Path get root path

import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {

  public static void main(String[] args) {
    Path p1 = Paths.get("C:", "myData", "Main.java");

    System.out.println(p1);//from  ww  w. j ava2 s.c  o m

    Path root = p1.getRoot();

    System.out.println(root);
  }
}



PreviousNext

Related