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

  • Home
  • SEARCH
  • 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 6678113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:12:15+00:00 2026-05-26T04:12:15+00:00

I m trying to load properties file to create a configuration. namely foo.properties. What

  • 0

I m trying to load properties file to create a configuration. namely foo.properties.

What the best place to store this config file. Within the package where i will use initialize the using class? on the root level of the src?

Also, while accessing the files, i am using the location of the file in the file system: ie: c:\configs\foo.properties.

Is there a better practice for this? such as using the path relative to the project rather than the file system location? if yes, how can i reference the location of a property file within a project tree. such as:

src/
   /com.foo.bar
   /com.foo.car
   /com.foo.zar
   foo.properties

lets say i want to read the properties file to memory, how do i access this foo.properties without using the OS location/ or the location in the file system.

  • 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-26T04:12:16+00:00Added an answer on May 26, 2026 at 4:12 am

    If you want keep something close to your current structure then you can just add a resources folder, like so:

    src/
       /com.foo.bar
       /com.foo.car
       /com.foo.zar
    resources
       /foo.properties
    

    But I highly recommend following Maven directory structures, they really do give you a lot of flexibility:

    src/
        /main
            /java
                /com.foo.bar
                /com.foo.car
                /com.foo.zar
            /resources
                /foo.properties
    

    Regardless of what layout you go with I would recommend putting your resources in a folder structure matching one of your Java packages, that way you can easily load them as resources, avoiding your absolute vs relative file path conundrum. Something like this:

    src/
        /resources/
           /com/foo/bar/foo.properties
    

    And given a class com.foo.bar.MyClass you can do something like this:

    InputStream is = MyClass. getResourceAsStream("com/foo/bar/foo.properties");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load a custom log.properties file when my application is started. My
I am trying to load properties from a file (test.properties) The code I use
I am trying to load a directory from a properties file. I have the
I'm using Ant 1.8, JUnit 4.8.2. I'm trying to load a properties file and
I'm trying to load a properties file without using the actual path of the
I am trying to load info from a properties file and i have the
I'm trying to load properties, and if it is not exist to create one.
I am am trying to load a SQL table from a flat file. The
I'm trying to refer to a properties file in my NetBeans project using Maven.
I am doing an application with android 2.2, i created a file config.properties in

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.