A question about ASCII and java: I am reading files using java, all of them containing Uppercase letters, which I am supposed to convert into lowercase, in order to treat them with another algorithm, which looks for matches between sequences read from both files. This algorithm contains this kind of comparison:
for(int j = 0; j < pattern.length(); ++j)
{
//char a has a certain decimal value, so whatever char subtracted to char a
//will be an index between 0 and 25
int c = pattern.charAt(j) - 'a';
And the algorithm reading the files look like this:
Anyways, whenever I read files, I get an error with the provoked by the variable text, which is supposed to have only lowercase letters. This error: ArrayIndexOutOfBoundsException caughtjava.lang.ArrayIndexOutOfBoundsException: Index -87 out of bounds for length 26
When I use a predefined String with lowercases, everything works perfectly, the only problem comes when I read the text from a file.
Is there any other way to convert uppercases into lowercases in java?
I would be very grateful if you could point out my error.
Thank you very much in advance!