Java Path create from path component via Paths
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 . ja v a 2s. c o m } }