GVA*_*Art 1 javafx filechooser
如何使用 JavaFX 中的 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);
}
Run Code Online (Sandbox Code Playgroud)
File dest = fileChooser.showSaveDialog(window);
if (dest != null) {
try {
Files.copy(file.toPath(), dest.toPath());
} catch (IOException ex) {
// handle exception...
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10446 次 |
| 最近记录: |