ide/src/wombat/gui/text/SchemeTextArea.java
public void save() throws FileNotFoundException, IOException {
    	if (myFile == null) throw new FileNotFoundException("No file set");
    	
    	String text = getText();
    	
    	// Remove extra whitespace at the ends of lines.
    	if (WhitespaceEOL.matcher(text).find()) {
    		text = WhitespaceEOL.matcher(text).replaceAll("\n");
    	}
    	
    	// Remove extra whitespace at the end of the file.
    	if (text.length() > 0 && Character.isWhitespace(text.charAt(text.length() - 1))) {
	    	text = text.replaceAll("\\s+$", "");
    	}

    	// Replace lambda character with lambda string
    	if (text.contains("\u03BB")) {
    		text = text.replace("\u03BB", "lambda");
    	}
    	
    	// If the file already exists (and the option is set), copy the old version to a backup file.
    	// Don't save a backup of a backup.
    	if (myFile.exists() && Options.BackupOnSave && myFile.getCanonicalPath().charAt(myFile.getCanonicalPath().length() - 1) != '~') {
    		File backupFile = new File(myFile.getCanonicalPath() + "~");
    		
    		if(!backupFile.exists()) {
    			backupFile.createNewFile();
    	    }

    	    FileChannel source = null;
    	    FileChannel destination = null;

    	    try {
    	        source = new FileInputStream(myFile).getChannel();
    	        destination = new FileOutputStream(backupFile).getChannel();
    	        destination.transferFrom(source, 0, source.size());
    	    } finally {
    	        if(source != null) source.close();
    	        if(destination != null) destination.close();
    	    }
    	}
    	
    	// Write to file.
    	Writer out = new OutputStreamWriter(new FileOutputStream(myFile));
        out.write(text);
        out.flush();
        out.close();
        SavedHash = text.hashCode();
    }
/**
     * Save the document to its file (throws an exception if the file hasn't been set).
     * @throws FileNotFoundException, IOException If it doesn't work.
     */
Save the document to its file (throws an exception if the file hasn't been set).
@throws FileNotFoundException, IOException If it doesn't work.
Save the document to its file ( throws an exception if the file hasn ' t been set ) . @throws FileNotFoundException IOException If it doesn ' t work .
public void save() throws FileNotFoundException, IOException {
    	if (myFile == null) throw new FileNotFoundException("No file set");
    	String text = getText();
    	if (WhitespaceEOL.matcher(text).find()) {
    		text = WhitespaceEOL.matcher(text).replaceAll("\n");
    	}
    	if (text.length() > 0 && Character.isWhitespace(text.charAt(text.length() - 1))) {
	    	text = text.replaceAll("\\s+$", "");
    	}
    	if (text.contains("\u03BB")) {
    		text = text.replace("\u03BB", "lambda");
    	}
    	if (myFile.exists() && Options.BackupOnSave && myFile.getCanonicalPath().charAt(myFile.getCanonicalPath().length() - 1) != '~') {
    		File backupFile = new File(myFile.getCanonicalPath() + "~");
    		if(!backupFile.exists()) {
    			backupFile.createNewFile();
    	    }
    	    FileChannel source = null;
    	    FileChannel destination = null;
    	    try {
    	        source = new FileInputStream(myFile).getChannel();
    	        destination = new FileOutputStream(backupFile).getChannel();
    	        destination.transferFrom(source, 0, source.size());
    	    } finally {
    	        if(source != null) source.close();
    	        if(destination != null) destination.close();
    	    }
    	}
    	Writer out = new OutputStreamWriter(new FileOutputStream(myFile));
        out.write(text);
        out.flush();
        out.close();
        SavedHash = text.hashCode();
    }
public void save ( ) throws FileNotFoundException , IOException { if ( myFile == null ) throw new FileNotFoundException ( "No file set" ) ; String text = getText ( ) ; if ( WhitespaceEOL . matcher ( text ) . find ( ) ) { text = WhitespaceEOL . matcher ( text ) . replaceAll ( "\n" ) ; } if ( text . length ( ) > 0 && Character . isWhitespace ( text . charAt ( text . length ( ) - 1 ) ) ) { text = text . replaceAll ( "\\s+$" , "" ) ; } if ( text . contains ( "\u03BB" ) ) { text = text . replace ( "\u03BB" , "lambda" ) ; } if ( myFile . exists ( ) && Options . BackupOnSave && myFile . getCanonicalPath ( ) . charAt ( myFile . getCanonicalPath ( ) . length ( ) - 1 ) != '~' ) { File backupFile = new File ( myFile . getCanonicalPath ( ) + "~" ) ; if ( ! backupFile . exists ( ) ) { backupFile . createNewFile ( ) ; } FileChannel source = null ; FileChannel destination = null ; try { source = new FileInputStream ( myFile ) . getChannel ( ) ; destination = new FileOutputStream ( backupFile ) . getChannel ( ) ; destination . transferFrom ( source , 0 , source . size ( ) ) ; } finally { if ( source != null ) source . close ( ) ; if ( destination != null ) destination . close ( ) ; } } Writer out = new OutputStreamWriter ( new FileOutputStream ( myFile ) ) ; out . write ( text ) ; out . flush ( ) ; out . close ( ) ; SavedHash = text . hashCode ( ) ; }
Save the document to its file (throws an exception if the file hasn't been set).
Save the document to its file ( throws an exception if the file hasn ' t been set ) .
// Remove extra whitespace at the ends of lines. // Remove extra whitespace at the end of the file. // Replace lambda character with lambda string // If the file already exists (and the option is set), copy the old version to a backup file. // Don't save a backup of a backup. // Write to file.