I am learning Java and this is what I realized regarding different paths:
Relative -incomplete path that exists relative to some directory, for example: \ data \ file.txt Absolute -full path starting from drive: C: \ users \ data \ file.txt
What is the canonical path and why is it needed? I tried to understand the English-language sources (I don't know English well), but I only realized that the canonical path lacks dynamic links (what is this?) And things like: ... \ (again, what is this?).
Please explain in simple terms what it is.
Answer # 1
Honestly, this is the first time I came across this name. But the first link explains this: In different operating environments (not in Windows), it is possible to make the path to a specific file such that it will not work in Windows. For example, on an ext4 filesystem, you can reference it like this:
\ var \ some \ there \ here \ where \ not \ be \ .. \ .. \ point \ file.txt
It sometimes makes sense when you create a path using a script that runs from some folder inside the system and stupidly substitutes ".. \ .. \ point \ file.txt" to the path to the current subdirectory. But in this case, the path:
\ var \ some \ there \ where \ point \ file.txt
will lead to the same file. Just like the path:
.. \ .. \ point \ file.txt will also lead to this file if you are in
you are currently in the folder:
\ var \ some \ there \ here \ where \ not \ be \
And so. The "canonical path" is the path that will be as simple and strict as possible. "canon". That is, without all these strange constructions. There is also a good example from the link:
absolute path: C: \ abc \ .. \ abc \ file.txt
canonical path: C: \ abc \ file.txt
Both of these paths are correct. But the second is canonical. Roughly speaking, Windows users always use only the canonical path.