how to read text file relative path

后端 未结 4 2170
迷失自我
迷失自我 2021-02-20 01:57

I have read sources here & there, but did not get the following code working. Basically, I wish to read a text file, named \'Administrator\' from the folder \'src\'. I will

4条回答
  •  不思量自难忘°
    2021-02-20 02:19

    This is a valid absolute path (on the systems I'm aware of):

        /path/to/directory/../../otherfolder/etc/
    

    So what the other answer was saying, was to get the path to the current directory with:

        String filePath = new File("").getAbsolutePath();
    

    Then concatenate your relative path with:

        filePath.concat("path to the property file");
    

提交回复
热议问题