Copying data files upon build in Java/Eclipse

前端 未结 3 1554
庸人自扰
庸人自扰 2020-12-17 18:00

Along with my java source, I have some data files that I would like to copy to the build dir when the source is build. Currently I am not using any build tools (e.g. maven o

3条回答
  •  余生分开走
    2020-12-17 18:07

    Eclipse isn't really meant to copy things around (it may have that feature and I don't know about it). Like you alluded to, that's a job for Maven or Ant. However, for your JUnit tests, you have a couple of options...

    • Open the data files based on a project relative path.
    • Use getResourceAsStream(filename) and add the data files to the build-path

提交回复
热议问题