title: Java - Load file, replace string, save
body: <p>I have a program that loads lines from a user file, then selects the last part of the String (which would be an int)</p>
  
  <p>Here's the style it's saved in:</p>
  
  <pre><code>nameOfValue = 0
  nameOfValue2 = 0
  </code></pre>
  
  <p>and so on. I have selected the value for sure - I debugged it by printing. I just can't seem to save it back in.</p>
  
  <pre><code>if(nameOfValue.equals(type)) {
          System.out.println(nameOfValue+" equals "+type);
              value.replace(value, Integer.toString(Integer.parseInt(value)+1));
          }
  </code></pre>
  
  <p>How would I resave it? I've tried bufferedwriter but it just erases everything in the file.</p>