title: Unable to edit Properties file loaded via Class.getResource()
body: <p>I'm attempting to write a method that will read a properties file using Class.getResource(), make changes to its values, and save the file.</p>
  
  <pre><code>public void saveDBConnectionValues(String user, String password, String host, int port) throws IOException, URISyntaxException
  {
      Properties dbProperties = new Properties();
  
      File f = new File(this.getClass().getResource("db.properties").toURI());
  
      BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(f))));     
  
      dbProperties.load(reader);
  
      reader.close();
  
      dbProperties.setProperty("user", user);
      dbProperties.setProperty("pw", password);
      dbProperties.setProperty("host", host);
      dbProperties.setProperty("port", Integer.toString(port));
  
      BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f)))
  
      dbProperties.store(writer, null);
  
      writer.close();
  
  }
  </code></pre>
  
  <p>My db.properties file is read correctly, but the store method doesn't seem to be working here. Can someone explain why this doesn't work, and what I need to do to get it working?</p>
  
  <p>Thanks</p>