My code doesn't work correctly, I'm trying to decrypt a message but instead I get something like , 0, 3, ,, , 5, 7, <, ;, , ;, 9, ,, (, 4, , , -, ,, ), (, , �, ]
Please help me find where am I am wrong:
public class WorkInFile {
public static void main(String[] args) throws IOException {
FileInputStream encoded=new FileInputStream("C://Games//encoded.txt");//contains ƪÄÖØÐîÃÜÙäÌÊÛÓÕÒáÄßÕÍǨ³¾êÉàÝâÝãƒâÝäìÚÇäÖçÅáâÄÄÌØÐƭèÑØǑÚÚŲã¨
FileInputStream coded = new FileInputStream("C://Games//code.txt");//contains icbakwtbxxvcelsmjpbochqlltowxhlhvhyywsyqraargpdsycikmgeakonpiwcqmofwms
String text = encoded.toString();
String text2=coded.toString();
char[] chars=text.toCharArray();
char[] chars2=text2.toCharArray();
int index=0;
char[] res=new char[text.length()];
for (char aChar : chars) {
for (char c : chars2) {
res[index] = (char) (aChar - c);
}
index++;
}
String result= Arrays.toString(res);
System.out.println(result);
}
}