Decrypt - alphabet shift
Hi guys,
As part of my learning process I have taken on the challenges athttp://www.pythonchallange.com I have been working on the level 2 challenge in which part of the challenge involves decrypting the following text
"g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."
The key to the above is to simply shift all letters 2 places forward ie 'a' becomes 'c','d' becomes 'f' etc.I have solved the challenge easily by using python as well as using my bash shell.I have tried implementing the solution in java but one or two of the caharacters
come out jumbled ('a' as '{' and 'b' as '|' ) and I cannot understand why.Could someone please look over my code (below) as help me understand where I am going wrong.
import java.io.*;
publicclass decrypt
{
publicstaticvoid main(String[] args)throws Exception
{
BufferedInputStream infile =new BufferedInputStream(new FileInputStream("/home/dave/riddle2.txt"));
PrintWriter outfile =new PrintWriter(new FileOutputStream("/home/dave/riddleSoln.txt"));
while (infile.available()!=0)
{
int ch= infile.read();
int sh=ch+2;
int text = sh;
System.out.print((char)text);
outfile.print((char)text);
}
infile.close();
}
}
I have saved the text in the file riddle.txt.I also wanted to write the solution to a file (practising I/O) but have found that though 'outfile.println()' works, 'outfile.print() does not do anything.
Any assistance would be appreciated.
Thanks

