Where to put a textfile I want to use in eclipse?

后端 未结 9 652
误落风尘
误落风尘 2020-11-30 02:31

I need to read a text file when I start my program. I\'m using eclipse and started a new java project. In my project folder I got the \"src\" folder and the standard \"JRE S

9条回答
  •  不知归路
    2020-11-30 03:18

    Just create a folder Files under src and put your file there. This will look like src/Files/myFile.txt

    Note: In your code you need to specify like this Files/myFile.txt e.g.

    getResource("Files/myFile.txt");
    

    So when you build your project and run the .jar file this should be able to work.

提交回复
热议问题