int next - in.read(); if (next == -1) done = true; else { byte b = (byte)next; byte c = encrypt(b); //call the method to encrypt the byte out.write(c) }