我在JavaFX中开发了一个appication。 Alreadey我从TableView中选择文件并希望使用FileChooser将其保存在另一个目录中我该怎么做?
public static void clickDownloadButton(String filename,Stage window){
File file = new File(filename);
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Save file");
fileChooser.showSaveDialog(window);
}
答案 0 :(得分:2)
File dest = fileChooser.showSaveDialog(window);
if (dest != null) {
try {
Files.copy(file.toPath(), dest.toPath());
} catch (IOException ex) {
// handle exception...
}
}