By equivalence, i mean logical equivalence, not the String comparison.
E.g. if I do Files.newBufferedReader(Paths.get("file.txt", System.getProperty("user.home")) and Files.newBufferedReader(Paths.get("~").resolve(Paths.get("file.txt"))), will I get the same file on Windows and other systems?
Asked
Active
Viewed 884 times
-1
sandwwraith
- 299
- 1
- 2
- 10
-
4No. Only shells understand `~`. It isn't a valid path component in the file system. – user207421 Dec 15 '17 at 23:19
-
"Home" on Windows is highly subjective. The duplicate should enlighten you on that regard. – Makoto Dec 15 '17 at 23:29
1 Answers
1
Of course no. Tilde character has special meaning in shell. It points to HOME variable. In Java ~ is like any other file name. In addition in Windows you cannot use ~ as home directory equivalent.
Koziołek
- 2,791
- 1
- 28
- 48