My previous post launched a three-part series on NIO.2 recipes. I presented three recipes for copying files, deleting files and directories, and moving files. In this post, I present path-related recipes (such as obtaining paths and retrieving path information), file/directory-testing recipes (such as testing file/directory existence), and attribute-oriented recipes.
Obtaining Paths
Q: How do I obtain a java.nio.file.Path object?
A: You obtain a Path object, which locates a file or directory in a file system via a sequence of name elements, by calling either of the following static methods in the java.nio.file.Paths class: