Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一种将文件保存在 Java (Eclipse RCP) 应用程序中的解决方案,并可选择在保存文件后立即打开文件。类似的是,当浏览器保存允许打开的已下载文件时。一个简单的 FileDialog 没有这样的选项。
我认为,您需要在保存文件后自己打开文件。
执行以下操作(在 Windows 中):
String cmd = "cmd.exe /c start "; String file = "path\version.txt"; //TODO: your file path here Runtime.getRuntime().exec(cmd + file);
类似的方法可以应用于linux环境。自己搜索。
如果您需要 JFileChooser 中的选项(可能是复选框),您可以扩展 JFileChooser 并添加您的功能。