How to access a resource file using relative path in play framework project?

心已入冬 提交于 2019-12-01 14:18:35

问题


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:


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

VirtualFile vf = VirtualFile.fromRelativePath("filename.csv");


来源:https://stackoverflow.com/questions/6430765/how-to-access-a-resource-file-using-relative-path-in-play-framework-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!