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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:06:53+00:00 2026-06-14T04:06:53+00:00

I am currently loading a properties file like this: private Properties loadProperties(String filename) throws

  • 0

I am currently loading a properties file like this:

private Properties loadProperties(String filename) throws IOException{
        InputStream in = ClassLoader.getSystemResourceAsStream(filename);
        if (in == null) {
            throw new FileNotFoundException(filename + " file not found");
        }
        Properties props = new Properties();
        props.load(in);
        in.close();
        return props;
    }

However, at the moment my file lays at the scr\user.properties path.

But when I want to write to a properties file:

properties.setProperty(username, decryptMD5(password));
        try {
            properties.store(new FileOutputStream("user.properties"), null);
            System.out.println("Wrote to propteries file!" + username + " " + password);

That piece of code generates me a new file at the root folder level of my project.

BUT I want to have one file to write\read.

Therefore how to do that?

PS.: When I want to specify the path I get “Not allowed to modify the file…”

  • 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-06-14T04:06:54+00:00Added an answer on June 14, 2026 at 4:06 am

    The reason a new file is created because you are trying to create a new file when you are writing. You should first get handle to the user.properties that you want to write to as File object and then try to write to it.

    The code would look something along the lines of

    properties.setProperty(username, decryptMD5(password));
    try{
        //get the filename from url class
        URL url = ClassLoader.getSystemResource("user.properties");
        String fileName = url.getFile();
    
        //write to the file
        props.store(new FileWriter(fileName),null);
        properties.store();
    }catch(Exception e){
        e.printStacktrace();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently loading properties from an XML file in Ant. However, I'd like
I have a properties file that I currently have in this folder: /src/webapp/WEB-INF/classes/my.properties I
I am reading properties file from java DAO implementation for loading properties object as
I am currently testing this environment and would like to ask about the best
I'm having some issues with loading a (.properties) file from the webcontent folder in
Currently I am loading data from a previous session into my application using the
Currently,I know how to do a lazy implementation of the loading procedure of the
I am currently looking at jQuery mobile and its system of loading web pages
We're currently using folders inside webroot to store images and videos which we're loading
I'm loading layers of images to make a single image. I'm currently stacking them

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.