What is Java NIO Path?
A file is identified by its path through the file system, beginning from the root node. For example in Windows a path is like
On linux, a path is like:
Relative and Absolute Path
To access a file, a relative path is combined with another path. You can't access the exact file location if you don't have the full path information. For example, /dev/java is a relative path but you can't say what is the parent directory for this path.
An absolute path contains the root and the complete directory information required to access a file. For example c:\home\david\pictures\mypic.jpg.
A symbolic link is a special kind of file that actually linked to some other target file. So on some system if you click a symbolic link it might open different application or file as defined inside the symbolic link.
The Path Interface
Path interface typically represent a system dependent file path. It has method like
getRoot() to get the different path component of a file.
The Path Class
Path is an interface and so you can't create an instance of it using a constructor. Therefore you have to use a method that return
Path. For example, you can use
get() method of
Paths class to get a
public static Path get(URI uri)
It converts the given URI to a