I have a string that needs to be read using the Scanner class from the beginning to the \n character. The problem is that the source stream in my case may contain the character \u2028. I know that the Scanner class uses the pattern "\r\n|[\n\r\u2028\u2029\u0085]" to separate lines, for this reason scanner.nextLine() on input line:
1 2 3 4 5 '\u2028' 6 7 8 will only read 1 2 3 4 5
I think that if I could force the scanner to use the pattern [\n\r\u2029\u0085] (default scanner pattern without NEW_LINE symbol) that would solve my problem. How can I read the entire string ignoring the \u2028 symbol ?
nextLine()instead ofreadLine()? Can't you usescanner.useDelimiter("[\n\r\u2029\u0085]")and then usescanner.next()?.useDelimiter("\\R")."\\R"Matches any Unicode line-break sequence, that is equivalent to\u000D\u000A|[\u000A\u000B\u000C\u000D\u0085\u2028\u2029].