title: JavaFX 2.2 Get selected file extension
body: <p>I don't know how to get selected file extension. I have seen that developers ask this question frequently, but I could find and proper answer. I know it is a bug (<a href="http://javafx-jira.kenai.com/browse/RT-18836" rel="nofollow noreferrer">http://javafx-jira.kenai.com/browse/RT-18836</a>), but anyways, is there any solutions for it. I wanto to save my linechart as .PDF or .PNG file. My code for both files works fine. But I just can't stand not to get selected file. Is there any solution possible? I see that Java has built in function for this issue.</p>
  <p>This solution is not relevant for me:
  <a href="https://stackoverflow.com/questions/12521828/javafx-filechooser-not-returning-file-extension-for-windows">JavaFX FileChooser not returning file extension for Windows</a></p>
  <p>My code is:</p>
  <pre><code> FileChooser fileChooser = new FileChooser();
   FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter(&quot;PDF file(*.pdf)&quot; ,&quot;      
   *.pdf&quot;);
  
   fileChooser.getExtensionFilters().add(extFilter);
   extFilter = new FileChooser.ExtensionFilter(&quot;PNG files (*.png)&quot;, &quot;*.png&quot;);
   fileChooser.getExtensionFilters().add(extFilter);
   fileChooser.setTitle(&quot;Save as&quot;);
   File file = fileChooser.showSaveDialog(primaryStage);
  </code></pre>
  <p>Then I get file path without extensions:</p>
  <pre><code> String filePath = file.getAbsolutePath();
  </code></pre>