I have a .csv file, that must be read on application startup.
How can I make play to copy this file to target (to "run" or "start" it).
I'm trying to access this file in Global-class with Global.class.getResourceAsStream("/file.csv")
, but the result is always null.
OK - thanks. I have managed it with my file in conf/ressources folder and loading it with /ressources/file.csv path
You can create a
resources
folder in yourconf
folder, put your file there, and then create anInputStream
by callingNote that you should not start the path with a
/
, because then the application will not be able to resolve the path and throw ajava.lang.ExceptionInInitializerError: null
on startup.You can put it in
test/resources/file.csv
folder in the test folder of play project. Then you can access it in scala withCheck out this blog post.
You can put it in several places:
app
folderconf
folder: I'd go for this one, by creating aconf/ressources
folder