1FileChooser fileChooser = new FileChooser();
2
3//Set extension filter for text files
4FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("TXT files (*.txt)", "*.txt");
5fileChooser.getExtensionFilters().add(extFilter);
6
7//Show save file dialog
8File file = fileChooser.showSaveDialog(primaryStage);
9//Its important towrite showSaveDialog!!!