Ok, I've never seen a while loop like this. Please can someone help explain this:
CipherInputStream cis = new CipherInputStream(new FileInputStream(new File("plaintext.txt")),cipher);
FileOutputStream fos = new FileOutputStream(new File("ciphertext.txt"));
byte[] cipherTextBytes = new byte[8];
int i = 0;
while((i=cis.read(cipherTextBytes))!= -1) {
fos.write(cipherTextBytes,0,i);
}
Ignore the whole CipherInputStream object if you don't understand it. Basically it's for cryptography. Just look at the while loop. I saw this in a textbook and it actually compiles. cis.read() method is of type int and will return -1 once there's no more byte to read, so I think I get why there's a "= -1" in the while loop. What I don't get is why there's a "i=cis.read()".