UNB/ CS/ David Bremner/ teaching/ old/ cs1083/ java/ Rot13.java
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileWriter;
public class Rot13{

    public static void main(String [] args) throws IOException{
        InputStreamReader in=new InputStreamReader(new FileInputStream(args[0]));
        FileWriter out=new FileWriter(args[1]);

        int inChar=in.read();
        while (inChar>=0){
            // top sekrit encryption,
            // algorithm from www.miranda.org.~jkominek/rot13
            char outChar = Character.toUpperCase((char)inChar);
            if ('A' <= outChar && outChar <= 'Z'){
                outChar = (char)(((int)outChar - 'A' + 13) % 26 + 'A');
            }
            if (Character.isLowerCase((char)inChar)){
                outChar= Character.toLowerCase(outChar);
            }
            out.write(outChar);
            inChar=in.read();
        }
        out.close();
    }



}
//