title: Remove filename extension in Java
body: <p><em>(Without including any external libraries.)</em></p>
  
  <p>What's the most efficient way to remove the extension of a filename in Java, without assuming anything of the filename?</p>
  
  <p>Some examples and expected results:</p>
  
  <ul>
  <li>folder > folder </li>
  <li>hello.txt > hello</li>
  <li>read.me > read</li>
  <li>hello.bkp.txt > hello.bkp</li>
  <li>weird..name > weird.</li>
  <li>.hidden > .hidden</li>
  </ul>
  
  <p>(or should the last one be just <em>hidden</em>?)</p>
  
  <p><strong>Edit</strong>: The original question assumed that the input is a filename (not a file path). Since some answers are talking about file paths, such functions should also work in cases like:</p>
  
  <ul>
  <li>rare.folder/hello > rare.folder/hello</li>
  </ul>
  
  <p>This particular case is handled very well by Sylvain M's answer.</p>