7

I am wondering if there is a designated place for resource files in a Grails application? I have a csv file that gets loaded into a map (nothing major) but didn't quite know where to put it in the project.

So my question is, is there a dedicated place in the project to place this file? (If so, where?) Or is it better to place it outside of the project?

1 Answer 1

5

If the csv is going to need updating from time to time, I'd put it external to your grails folder, and point to it from config.groovy.

If it's basically a static file, I'd put it in src/java/resources, and load it with something like this.class.getResource("/resources/file.csv") as you would with a regular java app

2
  • Ah, alright it will have to be updated from time to time. Thank you for the reply Tim May 20, 2011 at 21:26
  • 2
    Or use: Resource resource = new ClassPathResource("resources/file.csv") (added as edit, but it haven't been approved) Jul 31, 2013 at 4:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.