title: Java config.properties file won't save
body: <p>I have the following class that should allow to:</p>
  
  <ol>
  <li>Send the caller the value of a property,</li>
  <li>Set a new value for a property and save the Property file.</li>
  </ol>
  
  <p>Sending the value of a property works.
  Setting a new value for a property, and saving the file, that part don't work.</p>
  
  <p>What is wrong?  </p>
  
  <p>I already searched a lot and many different ways are discussed everywhere, nothing that can help me.  That's why I have to ask here.</p>
  
  <p>Many thanks to anybody who can help me!</p>
  
  <pre><code>public class Config {
  private Properties props = new Properties();
  private String strFilePath = "Config.properties";
  private File configFile = new File(strFilePath);
  
  public Config(){
      try {
          InputStream in = Config.class.getClassLoader().getResourceAsStream(strFilePath);
          props.load(in);
  
          }catch(IOException ex){
              System.out.println(ex);
          }
  }
  public String getPropriete(String sPropriété){
      String strResult = "";
      try{
          strResult = props.getProperty(sPropriété);
      }catch(Exception e){
          System.out.println(e);
          strResult = "";
      }
      return strResult;
  }
  public void setPropriete(String sPropriété, String sValeur){
      try{
          System.out.println(sPropriété + " --&gt; " + sValeur);
          props.setProperty(sPropriété, sValeur);
          FileOutputStream fos = new FileOutputStream(strFilePath);
          props.store(fos, null);
          props.save(fos, null);
          Writer out = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
          out.flush();
          out.close();
          fos.close();
      }catch(Exception e){
          System.out.println(e);
      }
  }
  </code></pre>
  
  <p>}</p>