因为我有用于打开 Open with dialog Box for windows 的 java 程序,如下所示:-
File file = new File("D:/new.txt");
ProcessBuilder builder = new ProcessBuilder("RUNDLL32.EXE", "SHELL32.DLL,OpenAs_RunDLL", file.getAbsolutePath());
builder.redirectErrorStream(); builder.redirectOutput(); Process process = builder.start(); process.waitFor();
但我希望我的代码在 Mac 和 Linux 中都能工作??? 请给出必要的回复和链接?
最佳答案
你可以选择JFileChooser,所有平台都在内部调用它的java类。示例
JFileChooser jfc= new JFileChooser() //You can choose the current directory or filesystemview
jfc.showOpenDialog() //or showSaveDialog(), it chooses the title of dialog and the viewform
jfc.getSelectedFile() //or Files[], get the value put on saving or file select in opening
您可以选择过滤器(按扩展名、按名称等) 告诉我你的结果!
关于java - 我想要可以在 Windows、Mac 和 Linux 中打开“打开方式”对话框的 java 程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21363076/