How can I detect the end of a line in a file ?
I would like to detect an end-of-line in my .txt file but can't find the right way to do.
My program already detects the last word of the line so what I did is to look at each char of my last word using the "charAt()" method. More precisely, if I'm at position "i" of my word, I check whether the char(i+1) is equal to '\r' or '\n'.
Before that, I did a System.getProperty("line.separator") and it returned "\r\n". So obviously, the char right after the last char of my word should be '\r', no ?
When I'm positioned on the last char of my word and I try to do charAt(i+1), I get a "java.lang.StringIndexOutOfBoundsException".
My question is : how come I can't detect this '\r' with charAt() ? Is there some way to detect it ?
Thanks for your help!