Java- relative path of text file in main?

前端 未结 3 1935
-上瘾入骨i
-上瘾入骨i 2020-12-14 22:59

I was wondering how to specifiy a relative path name to a text file that is stored in my src folder of a java project. I would like to store a string with the path of this

3条回答
  •  隐瞒了意图╮
    2020-12-14 23:43

    If you are using eclipse, place your text file in the root of the project folder, outside the /src and /bin folders. It should be now accessible via a relative path directly.

    If you want to access a file in src folder, you have to append the /src/ prefix before the file path/name

提交回复
热议问题