In order to work with file system one must first be able to point to files and directories. The first thing that needs to be understood is the role of java.nio.file.Path
class, the way instances are created and its functionality. As mentioned in previous articles, Path
is just an abstraction of the file system location. This allows for the situations when directory does not even have to exist. NIO.2 presents more elegant solutions for getting the object representing file system location. This shields programmer from platform specific problems.
In general, Path
instances allow two types of operations:
- syntactic operations
- any operations related to the Path representation itself – hierarchy traversal, conversion, comparison and so on
- file operations
- operations that modify location, state or contents of a file represented by a path instance