Introduction
- This series is going to be dedicated to the basic understanding of Java. When ever I find myself asking, "How does this work ?". I will create a blog post and put it here. This series will not be in order so feel free to read what ever post you find most relevant.
What is a path?
In Java a path is a class and as the name implies, the path is a programmatic representation of a path in your file system.
A Path instance reflects the underlying platform. In Windows the path object uses the Windows syntax(C:\home\joe\foo). Your path may look different depending on your underlying operating system.
A Path is not system independent, you can not compare a path from two different operating systems and expect them to reach the same directory.
A Path object represents a path that is hierarchical and composed of a sequence of directory and file name elements. These elements are separated by a special separator called a delimiter. A Path object also contains a root component, that identifies the file system's hierarchy. The name of the element that we are accessing is the one farthest from the root directory(cat)
C:\foo\pie\cat
- The above code is an example of a path in the Windows environment. The "C:" is the root directory in Windows and it represents our C-drive, which is the main hard drive. The backslashes are examples of the delimitators and are used as a form of separation. cat is the element that we are accessing.
Top comments (0)