0

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.

Jonas
  • 121,568
  • 97
  • 310
  • 388
  • 2
    this post might help you http://stackoverflow.com/questions/6113435/how-to-find-out-which-line-separator-bufferedreaderreadline-used-to-split-the – Sergey Benner Feb 13 '12 at 01:53
  • Define "no luck". Using `read` will return the newline character, so something else in your code must be causing the problem you are seeing. – Tim Feb 13 '12 at 01:58
  • I was pushing all chars from read into an array and didn't see the \n in the array. I see it now, I was using the wrong read function. THanks for the help. –  Feb 13 '12 at 02:08

1 Answers1

2

I tried this and it works:

while((charT = reader.read()) != -1) {
if(charT != '\n')
System.out.println("Carriage Return!");
}
JZares
  • 187
  • 9