Get the Path Root - Java File Path IO

Java examples for File Path IO:Path

Description

Get the Path Root

Demo Code

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

public class Main {

    public static void main(String[] args) {

        Path path = Paths.get("C:", "folder1/folder2/folder4", "test.txt");
        System.out.println("Root of this path: " + path.getRoot());
    }/*from  w w  w.  ja  v  a  2s. c  o m*/
}

Result


Related Tutorials