gpt4 book ai didi

java - Java 扫描器的 nextLine 函数是否保证只在换行符上定界?

转载 作者:搜寻专家 更新时间:2023-11-01 02:03:55 25 4
gpt4 key购买 nike

我正在看这个功能的文档,他们似乎用词含糊不清。

Advances this scanner past the current line and returns the input that was skipped. This method returns the rest of the current line, excluding any line separator at the end. The position is set to the beginning of the next line. Since this method continues to search through the input looking for a line separator, it may buffer all of the input searching for the line to skip if no line separators are present.

对于“任何行分隔符”,我应该将其解释为 NUL、EM、FS、ETX 等,还是它遇到的第一个换行符?

我真的希望 javadoc 更明确一点。

最佳答案

OpenJDK's source code显示 nextLine() 使用此正则表达式作为行分隔符:

private static final String LINE_SEPARATOR_PATTERN =
"\r\n|[\n\r\u2028\u2029\u0085]";

关于java - Java 扫描器的 nextLine 函数是否保证只在换行符上定界?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39176787/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com