title: How to overwrite one property in .properties without overwriting the whole file?
body: <p>Basically, I have to overwrite a certain property in a .properties file through a Java app, but when I use Properties.setProperty() and Properties.Store() it overwrites the whole file rather than just that one property.</p>
  
  <p>I've tried constructing the FileOutputStream with append = true, but with that it adds another property and doesn't delete/overwrite the existing property.</p>
  
  <p>How can I code it so that setting one property overwrites that specific property, without overwriting the whole file?</p>
  
  <p>Edit:  I tried reading the file and adding to it.  Here's my updated code:</p>
  
  <pre><code>FileOutputStream out = new FileOutputStream("file.properties");
  FileInputStream in = new FileInputStream("file.properties");
  Properties props = new Properties();
  
  props.load(in);
  in.close();
  
  props.setProperty("somekey", "somevalue");
  props.store(out, null);
  out.close();
  </code></pre>