September 2019
Intermediate to advanced
816 pages
18h 47m
English
We understand shortcuts to be the . (current directory) and .. (parent directory) notations. This kind of path can be normalized via the normalize() method. This method eliminates redundancies such as . and directory/..:
Path path = Paths.get( "C:/learning/packt/chapters/../JavaModernChallenge.pdf") .normalize();Path path = Paths.get( "C:/learning/./packt/chapters/../JavaModernChallenge.pdf") .normalize();Path path = FileSystems.getDefault() .getPath("/learning/./packt", "JavaModernChallenge.pdf") .normalize();Path path = Path.of( "C:/learning/packt/chapters/../JavaModernChallenge.pdf") .normalize();Path path = Path.of( "C:/learning/./packt/chapters/../JavaModernChallenge.pdf") .normalize();