I ran into the same problem. My solution was to create a new file and add the file extension as a string in the file constructor.
If you want users to be able to select and overwrite an existing file, make sure you add a check to make sure that the original save file does not contain a specific extension before adding, otherwise you will get something like "test". xls.xls ".
FileChooser fc = new FileChooser(); FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("XLS File (*.xls)", "*.xls"); fc.getExtensionFilters().add(extFilter); File save = fc.showSaveDialog(stage); save = new File(save.getAbsolutePath()+".xls"); FileOutputStream fileOut = new FileOutputStream(save);
source share