سؤال

I have a string that looks something like this:

"foobar\n"

I read this string using a BufferedReader. I need to be able to detect whether or not there is a new line present. I was using readLine, but I switched to read so I could grab the \n but no luck.

هل كانت مفيدة؟

المحلول

I tried this and it works:

while((charT = reader.read()) != -1) {
if(charT != '\n')
System.out.println("Carriage Return!");
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top