FileNotFoundException after exporting as .jar file

后端 未结 2 791
粉色の甜心
粉色の甜心 2021-01-06 17:17

I\'m using Eclipse and developing a java application where I use of a local file. The file is inside the project folder, in a subfolder, say \"mydata/myfile.txt\" When I run

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-06 17:48

    When your app is exported as a jar, your config file is not available as a file, since it's wrapped up in the .jar file. Instead you should access it via ClassLoader.getResourceAsStream(). See this SO question for more background info.

提交回复
热议问题