title: Adding an infix between file name and extension using java 8
body: <p>In my code, I would like to transform a path of the form</p>
  
  <pre><code>/a/path/to/a/file/image.jpg
  </code></pre>
  
  <p>to</p>
  
  <pre><code>/a/path/to/a/file/image_resized.jpg
  </code></pre>
  
  <p>Currently, I am using the the following code which uses <code>FilenameUtils</code> from apache commons IO.</p>
  
  <pre><code>public Path resize(Path original) {
      String baseName = FilenameUtils.getBaseName(original.toString());
      String extension = FilenameUtils.getExtension(original.toString());
      return Paths.get(original.getParent().toString(), baseName + "_resized." + extension);
  }
  </code></pre>
  
  <p>I was wondering if some of this code could be enhanced using java 8 features, specifically:</p>
  
  <ul>
  <li>is there a java-8 way for extracting the extension and basename, without using a dependency on Apache Commons IO (FilenameUtils), and without regex (I prefer dependency on apache commons IO over using a regex here)</li>
  <li>joining to Paths without <code>toString()</code> in <code>Paths.get(existingPath.toString(), "path/to/append");</code></li>
  </ul>
  
  <p>The second part of the question is answered in <a href="https://stackoverflow.com/questions/412380/combine-paths-in-java">Combine paths in Java</a></p>