m_lastvisitedDirectory = sFile.getPath();
  public boolean save(StringBuffer buf) {    if (buf != null) {      JFileChooser fileChooser;      if (m_lastvisitedDirectory == null) {	fileChooser = new JFileChooser(		      new File(System.getProperty("user.dir")));      } else {	fileChooser = new JFileChooser(m_lastvisitedDirectory);      }      fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);      int returnVal = fileChooser.showSaveDialog(m_parentComponent);      if (returnVal == JFileChooser.APPROVE_OPTION) {	File sFile = fileChooser.getSelectedFile();	if (sFile.exists()) {	  m_lastvisitedDirectory = sFile.getPath();	  Object [] options = new String[4];	  options[0] = "Append";	  options[1] = "Overwrite";	  options[2] = "Choose new name";	  options[3] = "Cancel";		  JOptionPane jop = new JOptionPane("File exists",					     JOptionPane.QUESTION_MESSAGE,					    1,					    null,					    options);	  JDialog dialog = jop.createDialog(m_parentComponent, "File query");	  dialog.show();	  Object selectedValue = jop.getValue();	  if (selectedValue == null) {	  } else {	    for(int i=0; i<4; i++) {	      if(options[i].equals(selectedValue)) {		switch (i) {		  // append		case 0:		  return saveOverwriteAppend(buf, sFile, true);		  // overwrite		case 1: 		  return saveOverwriteAppend(buf, sFile, false);		  // pick new name		case 2:		  return save(buf);		  // cancel		case 3: break;		}	      }	    }	  }	} else {	  saveOverwriteAppend(buf, sFile, false); // file does not exist	}      } else {	return false; // file save canceled      }    }    return false; // buffer null  }