title: Get settings from a text file in Java
body: <p>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:</p>
  
  <pre><code># System configuration
  # Comments will automatically be excluded by the program
  
  radiomodemPort=20001
  
  sisnetPort=5562
  
  sisnetHost=213.229.135.3
  
  sisnetUser=jogg
  
  sisnetPass=jogg
  </code></pre>
  
  <p>The code written to read it is not working: it doesn't load any of the variables stored. My code is:</p>
  
  <pre><code>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&lt;Object&gt; 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 &amp;&amp; sisnetPortLoaded &amp;&amp; sisnetUserLoaded &amp;&amp; sisnetPassLoaded &amp;&amp; radiomodemPortLoaded))
              fillUnloadedSettings();
          return true;
      }
  </code></pre>
  
  <p>What's wrong?</p>