On Mon, 12 May 2025 21:59:29 GMT, Naoto Sato <na...@openjdk.org> wrote:
>> With the introduction of `stdin.encoding` >> ([JDK-8350703](https://bugs.openjdk.org/browse/JDK-8350703)), some guidance >> for users to decode `System.in` would be desirable. Adding examples in the >> field description would help. > > Naoto Sato has updated the pull request incrementally with one additional > commit since the last revision: > > Reflects more comments src/java.base/share/classes/java/util/Scanner.java line 89: > 87: * String aLine = sc.nextLine(); > 88: * } > 89: * } Now that I'm looking at the other examples, I have what I think is better example for using Scanner on System.in. Take this example and move it after the example below, which reads long values from the file `myNumbers`. The new example could do the same thing with the hasNextLong/nextLong loop. But instead it would read from System.in using the encoding specified by `stdin.encoding`. The example could explain that reading from files uses the default encoding (`file.encoding`) whereas reading from System.in should use `stdin.encoding` because on some systems this differs from the default encoding. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25155#discussion_r2085745213