Java Path create from 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 ava 2 s . c o m*/ } }