[jdk20] RFR: 8297288: Example code in Scanner class
Alan Bateman
alanb at openjdk.org
Sat Dec 10 08:18:01 UTC 2022
On Fri, 9 Dec 2022 18:32:37 GMT, Naoto Sato <naoto at openjdk.org> wrote:
> The example in `Scanner` directly uses `System.in` which may cause unwanted behavior when the default charset and the console charset differ. Using `Console.reader()` is more appropriate. Also changed examples into snippets.
src/java.base/share/classes/java/util/Scanner.java line 58:
> 56: * var con = System.console();
> 57: * if (con != null) {
> 58: * Scanner sc = new Scanner(con.reader()); // @link substring="reader()" target="java.io.Console#reader()"
The link tag can be put on the previous line if you want. It just requires terminating it with a colon (":"). I've found that useful in a few places.
-------------
PR: https://git.openjdk.org/jdk20/pull/14
More information about the core-libs-dev
mailing list