I am trying to read a text file which has -
hello James! How are you today!
I want to read the each character in the string till i find EOL ch
Your problem is about magic numbers.
your while will enter into an infinite loop in the case charAt(21)!='\n' && charAt(22)!='\r'
those two integers shall be increased inside the loop.
charAt(i)!='\n' && charAt(i+1)!='\r' ::inside loop i++