Regardless of which operating system you can get, for example, a demo.txt file, for example
File file = new File("/d:/user/demo.txt");
on windows where the file is located in D:\user\and
File file = new File("/usr/demo.txt");
in *nixor *nuxwhere the file is in/usr/
In addition, the file, if it wants to access relatively, can be executed as (taking into account the Windows example):
Suppose I am in a song catalog in D: like:
D:/
|
|---songs/
| |
| |---Main.java
|
|---user/
|
|---demo.txt
Main.java, .
File file = new File("../user/demo.txt");