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 7180981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:27:41+00:00 2026-05-28T17:27:41+00:00

I was previously hard coding a path to load a json file like so:

  • 0

I was previously hard coding a path to load a json file like so:

JsonParser parser = jf.createJsonParser(new File("/some/path/here/myapp/WEB-INF/settings.json"));

So I tried to extract it out to a properties file like so, files.properties:

path.to.json=/some/path/here/myapp/WEB-INF/settings.json

Now how can I modify my call to jf.createJsonParser to load the file using the path from the files.properties path.to/json key?

  • 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-28T17:27:43+00:00Added an answer on May 28, 2026 at 5:27 pm

    I’m a little confused. Your title indicates that you are looking for a Spring solution, but you are not using IOC here, from what I can tell. Otherwise, you would be injecting the JsonParser bean and not instantiating it within your code.

    Without seeing the global structure of what you are doing, I would do the following (assuming that you have Spring properly configured).

    applicationContext.xml:

    <bean id="jsonParser" factory-bean="<jf bean definition>" factory-method="createJsonParer">
       <constructor-arg>classpath:/settings.json</constructor-arg>
    </bean>
    

    Then within your actual class that uses the JsonParser, have it autowired for simplicity sake:

    class myClass{
      @Autowired
      JsonParser jsonParser;
    
      public void myMethod(){
        String data = jsonParser.doSomthingNeatHere()....
      }
    
    }
    

    I’ve assumed that JsonParser is of scope prototype, but you can change it to singleton if that matches your needs more appropriately. As well, I’ve only given you a little pseudo-code to give you the idea of how to allow Spring to manage the life-cycle of the bean as opposed to you instantiating it yourself.

    You can read more about Spring 3 and IOC here if you need additional reference.

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

Sidebar

Related Questions

If this was previously talked about, I'm sorry, I had a hard time searching
Previously, I asked the question . The problem is the demands of our file
Previously answered questions here said that this was the fastest way: //nl is a
I'm running into a VERY frustrating pointer issue. I previously posted here: TOUGH: Dealing
I am upgrading my site from some old spaghetti coding to some nice, clean
I need to add a new matrix to a previously existant matrix, but on
Since new Xcode 3.2 I find it very hard to add Quartz Core Framework.
When writing PHP code, you can cause some really hard to track down parsing
I'm trying hard to find out how to use the file chooser button properly.
This is a question regarding best coding practices. I would like to know the

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.