import java.io.*;
public class Tester {
		public static void main(String args[]){
	    File input = new File("src.txt");
	    File output = new File("dest.txt");
	    long l1 = input.length();
	    long l2 = output.length();
	    long l1af, l2af;
	    int spaces = 0, newlines = 0;
	    if(input.exists() == false)
	    	try{
	    	throw new FileNotFoundException();
	    	}
	    catch(FileNotFoundException ex){
	    	System.out.println("Input file was not found");
	    }
	    else
		try{
	        FileReader fin = new FileReader(input);
	        FileWriter fout = new FileWriter(output);
		int c;
		while ((c = fin.read()) != -1){
	        if(c == ' '){
	        	fout.write("@");
	        	spaces++;
	        }
	        else if(c == '\n'){
	        	fout.write("\r\n");
	        	fout.write("\r\n");
	        	newlines++;
	        }
	        else fout.write(c);
	        }
        fin.close();
        fout.close();
		l1af = input.length();
		l2af = output.length();
        System.out.println("Size before:");
        System.out.println("src.txt " +l1 +", dest.txt " +l2);
		System.out.println("Size after:");
		System.out.println("src.txt " +l1af +", dest.txt " +l2af);
		System.out.println(spaces +" spaces replaced, " +newlines +" newlines added.");
		}

	catch(FileNotFoundException e){
		System.out.println("Input file stream didn't open (?)");
	}
	catch (IOException io){};
		}
	}
