salve!
ho un JFC nel quale ho già il controllo sull'esistenza di un file con lo stesso nome.
codice:
public class FileChooserTxt {

    private static File f = null;

    public void salva() throws IOException, WriteException {
        JFileChooser fc = new JFileChooser();
        fc.setDialogTitle("Save TXT");
        fc.setApproveButtonText("Save");
        fc.setApproveButtonToolTipText("Approve file");

        FileFilter txtFilter = new GenericFileFilter("File *.txt", "txt");
        //fc.addChoosableFileFilter(txtFilter);
        fc.setFileFilter(txtFilter);

        int returnVal = fc.showSaveDialog(fc);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            f = fc.getSelectedFile();
            FileFilter selectedFilter = fc.getFileFilter();
            if (f.getName().indexOf('.') == -1) {
                if (selectedFilter == txtFilter) {
                    f = new File(f.getPath() + ".txt");
                } else {
                    f = new File(f.getPath() + ".txt");
                }
            }
            if (f.exists()) {
                String msg = MessageFormat.format("The entry ''{0}'' already exists.\nDo you want to replace it?", new Object[]{f});
                int r = JOptionPane.showConfirmDialog(null, msg, "Confirm", JOptionPane.YES_NO_OPTION);
                if (r == JOptionPane.NO_OPTION) {
                    return;
                }
            }
............
        }
    }
}
vorrei però avere la possibilità di decidere se sovrascrivere il file o aggiungere al file.
ovviamente la decisione è random e presa di volta in volta.
è possibile in qualche modo aggiungere questa decisione??