Java Path create from path component via FileSystems
import java.nio.file.FileSystems; import java.nio.file.Path; public class Main { public static void main(String[] args) { Path p1 = FileSystems.getDefault().getPath("C:", "myData", "Main.java"); System.out.println(p1);//from w w w . j a v a 2 s . co m } }