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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:36:38+00:00 2026-06-08T21:36:38+00:00

I’m working over Eclipse, and I have created a res folder outside mi src

  • 0

I’m working over Eclipse, and I have created a res folder outside mi src folder. In it, I have created a text file called “config.cfg”. Looks like this:

# System configuration
# Comments will automatically be excluded by the program

radiomodemPort=20001

sisnetPort=5562

sisnetHost=213.229.135.3

sisnetUser=jogg

sisnetPass=jogg

The code written to read it is not working: it doesn’t load any of the variables stored. My code is:

private String sisnetHost;
private int sisnetPort;
private int radiomodemPort;
private String sisnetUser;
private String sisnetPass;

private boolean sisnetHostLoaded;
private boolean sisnetPortLoaded;
private boolean radiomodemPortLoaded;
private boolean sisnetUserLoaded;
private boolean sisnetPassLoaded;

public boolean getSettingsFromFile(){
        Properties config = new Properties();
        try {
            config.load(new FileInputStream("res/config.cfg"));
            Enumeration<Object> en = config.keys();
            while (en.hasMoreElements()) {
                String key = (String) en.nextElement();
                if(key.equals(sisnetHost)){
                    sisnetHost = (String)config.get(key);
                    sisnetHostLoaded = true;
                }
                if(key.equals(sisnetPort)){
                    sisnetPort = (Integer)config.get(key);
                    sisnetPortLoaded = true;
                }
                if(key.equals(sisnetUser)){
                    sisnetUser = (String)config.get(key);
                    sisnetUserLoaded = true;
                }
                if(key.equals(sisnetPass)){
                    sisnetPass = (String)config.get(key);
                    sisnetPassLoaded = true;
                }
                if(key.equals(radiomodemPort)){
                    radiomodemPort = (Integer)config.get(key);
                    radiomodemPortLoaded = true;
                }
            }

        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
            return false;
        } catch (IOException ex) {
            ex.printStackTrace();
            return false;
        }

        if(!(sisnetHostLoaded && sisnetPortLoaded && sisnetUserLoaded && sisnetPassLoaded && radiomodemPortLoaded))
            fillUnloadedSettings();
        return true;
    }

What’s wrong?

  • 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-08T21:36:39+00:00Added an answer on June 8, 2026 at 9:36 pm

    In your equals test, you’re comparing each key with your instance variables (which seem to have default values: null for objects, 0 for numbers etc.). Use the actual strings to test the keys:

    if(key.equals("sisnetHost")) // NOT if(key.equals(sisnetHost))
    

    Usually it’s recommended to to call equals on the literal / constant in order to eliminate the risk of a NPE:

    if ("sisnetHost".equals(key))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a reasonable size flat file database of text documents mostly saved in
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a bunch of posts stored in text files formatted in yaml/textile (from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't

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.