I am using MacBook. I have a file located under ~/temp/note.txt.
(~ represents home directory by default in terminal).
I want to access this file in my java code:
File fileDir = new File("~/temp"); // I get exist = false, why? boolean exist = fileDir.exist(); But my java code can't find the directory ~/temp. I guess it is because java code can't recognize ~ ? How to make it work ?
~is parsed by the shell. The issue that it doesn't work exists in all (other) programming languages.