JFileChooser fileChooser=new JFileChooser();
int returnValue=fileChooser.showOpenDialog(getContentPane());
if (returnValue==JFileChooser.APPROVE_OPTION){
File file=fileChooser.getSelectedFile();
txf_filename.setText(file.getAbsolutePath());
txf_length.setText(String.valueOf(file.length()));
}
File file = null;
JFileChooser fileChooser=new JFileChooser();
fileChooser.setSelectedFile(new File(appendix.getAppendixName()));
int returnValue=fileChooser.showSaveDialog(new JFrame("下载"));
if (returnValue==JFileChooser.APPROVE_OPTION){
file=fileChooser.getSelectedFile();
System.out.println(file.getPath());
//如果文件已经存在
if(file.exists()) {
int i = javax.swing.JOptionPane.showConfirmDialog(new JFrame(),"该文件已经存在,确定要覆盖吗?");
if(i == javax.swing.JOptionPane.YES_OPTION){
}else{
return ;
}
}
DownLoadClient download = new DownLoadClient();
download.downLoadFile(appendix.getId(), file.getPath());
}