concept Path in category java

This is an excerpt from Manning's book The Well-Grounded Java Developer.
We expect that you’ll most likely be wanting to use the new file I/O capabilities, so we’ll cover that in the greatest detail. You’ll begin by learning about the new filesystem abstraction, Path, and its supporting classes. Building on top of Path, you’ll work through common filesystem operations such as copying and moving files.
The following listing checks to see if the Path for a Java installation in /opt/platform is a symbolic link before trying to read its basic file attributes; we want to read the attributes for the real file location.
The Files class provides an isSymbolicLink(Path) method to check for a symbolic link
. It has a helper method to return the real Path that’s the target of the symbolic link
, so you can then read the correct file attributes
.
Path logFile = Paths.get("/tmp/app.log"); try (BufferedReader reader = Files.newBufferedReader(logFile, StandardCharsets.UTF_8)) { String line; while ((line = reader.readLine()) != null) { ... } }
. It has a helper method to return the real Path that’s the target of the symbolic link
, so you can then read the correct file attributes
.