JFileChooser fileChooser = new JFileChooser(); public String openFolder(String dialog_name)// 打开文件夹 { fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setDialogTitle(dialog_name); int ret = fileChooser.showOpenDialog(null); if (ret == JFileChooser.APPROVE_OPTION) { return fileChooser.getSelectedFile().getAbsolutePath();// 文件夹路径 } else return null; }