How to access a resource file using relative path

2019-02-21 12:28发布

My play framework project uses resource files like CSV files that I have under resources directory which I created under play project root directly so it is at the same level as other directories like app, public etc. From within Java or Scala files how can I open such files using path that is relative to the project root? This path should also work when I create a war and deploy the application.

1条回答
beautiful°
2楼-- · 2019-02-21 12:39

The VirtualFile class should do everything you need, especially the method 'fromRelativePath()'.

VirtualFile vf = VirtualFile.fromRelativePath("filename.csv");
查看更多
登录 后发表回答