Creating a path relative to the current folder

When we create a path that's relative to the current working folder, the path should not start with the file delimiter. If the current folder is named books and is under the C root, then the absolute path that's returned by the following snippet of code will be C:ookslearningpacktJavaModernChallenge.pdf:

Path path = Paths.get("learning/packt/JavaModernChallenge.pdf");
Path path = Paths.get("learning", "packt/JavaModernChallenge.pdf");

Path path = Path.of("learning/packt/JavaModernChallenge.pdf");
Path path = Path.of("learning", "packt/JavaModernChallenge.pdf");

Path path = FileSystems.getDefault()
.getPath("learning/packt", "JavaModernChallenge.pdf");
Path path = FileSystems.getDefault()
.getPath("learning/packt/JavaModernChallenge.pdf");
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset