-1
你好,有人可以告訴我正確的代碼,以便確認消息時,該文件被覆蓋問?覆蓋JFileChooser java
{
int index = cCont.getSelectedIndex();
log.info("index=" + index);
if (m_att.getEntryCount() < index)
return;
String fileName = getFileName(index);
String ext = fileName.substring (fileName.lastIndexOf("."));
log.config("Ext=" + ext);
JFileChooser chooser = new JFileChooser();
chooser.setDialogType(JFileChooser.SAVE_DIALOG);
chooser.setDialogTitle(Msg.getMsg(Env.getCtx(), "AttachmentSave"));
File f = new File(fileName);
chooser.setSelectedFile(f);
// Show dialog
int returnVal = chooser.showSaveDialog(this);
if (returnVal != JFileChooser.APPROVE_OPTION)
return;
File saveFile = chooser.getSelectedFile();
if (saveFile == null)
return;
log.config("Save to " + saveFile.getAbsolutePath());
m_attachment.getEntryFile(index, saveFile);
}