On Thu, 19 Jun 2025 10:57:52 GMT, Markus KARG <d...@openjdk.org> wrote:
>>> I think we should treat "\r\n" as a single line terminator? >> >> You are correct: that needs to be fixed: >> >> jshell> Reader r = new StringReader("hello\r\nworld") >> r ==> java.io.StringReader@480bdb19 >> >> jshell> r.readAllLines() >> $3 ==> [hello, , world] >> >> Thanks for the catch! > > `Scanner` seems to scan for even more characters: > https://github.com/openjdk/jdk/blob/c4fb00a7be51c7a05a29d3d57d787feb5c698ddf/src/java.base/share/classes/java/util/Scanner.java#L490 > > Would it make sense to resemble this? Would it make sense to simply use > `Scanner` directly? 🤔 The `readAllLines` method has a specification of line terminators that agrees with that of `BufferedReader::readLine` and `String::lines` and so we don't want to change it to be different. Unfortunately `Scanner` doesn't seem to have a specification of what it considers to be a line. Also unfortunately, its notion of line separators isn't the same as the regex pattern `\R`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25863#discussion_r2162547839