Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7001385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:47:46+00:00 2026-05-27T20:47:46+00:00

When my Grails application starts, I build up a data structure from a CSV

  • 0

When my Grails application starts, I build up a data structure from a CSV file downloaded from a remote URL. If the file is not accessible, I’d like to fall back to a local copy. Currently processing the file in the service layer, initiated using a Quartz job.

What is the best practice, using Groovy, for reading a local resource in Grails?

  • Where should I stash the file?
  • How do I safely and properly read the file?

General-case answers will be very acceptable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:47:47+00:00Added an answer on May 27, 2026 at 8:47 pm

    I think the best way to deal with this is to store the file’s location in an externalized configuration file.

    So, you’d determine a standardized location (such as /etc/myappname/CSVFileConfig.groovy), or pass the config file path in using an environment variable or something similar. See Externalized Configuration for examples.

    Then you can simply add the actual path to the local file to that extenal config, like so:

    // CSVFileConfig.groovy
    my.custom.csv.path = ...
    

    Finally, access it using normal config operations:

    // in your Quartz job
    def path = grailsApplication.config.my?.custom?.csv?.path
    if(!path) {
        // no file to load
    } else {
        // load file
    }
    

    As far as reading the file, what are your primary concerns? If you are using a CSV library, such as OpenCSV (used in most of the Grails libraries for CSV parsing), it will handle the opening and parsing of the file.

    For security issues beyond that, I’m not sure how to handle them in a generic way. It will depend on your specific scenario. I think the one coming from a URL has a higher risk factor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my grails application I want to read some values from properties file and
In my grails application I have an sql query that selects column data from
I have one grails application.In that I have one model class named Book. From
I started a grails application by grails create-app. For modularity, I feel like it
Inside a grails application, I need to upload a file under web-app/js, add a
I am developing grails application which uses file searching.For that I wrote the following
My Grails application has a large number of enums that look like this: public
I have build a grails application, which on login redirects users to different URLs
I have a Grails application, built to a war file (~30mb). When I attempt
I have a Grails application that I am migrating from 1.0.3 to 1.3.7 It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.