I am making a small Java program that encrypts files of any type. The way I do this is this: I open the input file, read it in a byte array with the same size as this file, then do the encoding and write the entire array to a .dat file called output. Dat To index an array of bytes, I use a variable of type int. Code:
for(int i : arr) { if(i>0) { arr[i] = arr[i-1]^arr[i]; } }
'arr' is an array of bytes with the same size as the input file.
The error I get is: CodingEvent.java:42: error: possible loss of accuracy
arr [i] = arr [i-1] ^ arr [i];
(arrows on the operator ^)
required: byte
found: int
What happened? could you help me?
source share