title: Concatenating to a file name before the ‘.’ Filename extension in Java
body: <p>I can’t seem to find a way of concatenating to a file name before the “.” extension in Java and I’m not entirely sure how I would go about this.</p>
  
  <p>I have already tried:</p>
  
  <pre><code>String s = r + "V1";
  </code></pre>
  
  <p>Where the variable <code>r</code> contains the value of <code>myFile.txt</code> and the output is: <code>myFile.txtV1</code>, but what I need to achieve is <code>myFileV1.txt</code> as I don’t want to overwrite the existing file with the same name but concatenate the <code>V1</code> before the <code>.</code> filename extension when the file is written.</p>
  
  <p>Thanks</p>