8260265: UTF-8 by Default

Reviewed-by: alanb, rriggs
This commit is contained in:
Naoto Sato 2021-08-30 21:13:59 +00:00
parent 32048536e9
commit 7fc8540907
22 changed files with 385 additions and 201 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -557,10 +557,11 @@ public final class Scanner implements Iterator<String>, Closeable {
/**
* Constructs a new {@code Scanner} that produces values scanned
* from the specified input stream. Bytes from the stream are converted
* into characters using the underlying platform's
* {@linkplain java.nio.charset.Charset#defaultCharset() default charset}.
* into characters using the
* {@linkplain Charset#defaultCharset() default charset}.
*
* @param source An input stream to be scanned
* @see Charset#defaultCharset()
*/
public Scanner(InputStream source) {
this(new InputStreamReader(source), WHITESPACE_PATTERN);
@ -629,11 +630,12 @@ public final class Scanner implements Iterator<String>, Closeable {
/**
* Constructs a new {@code Scanner} that produces values scanned
* from the specified file. Bytes from the file are converted into
* characters using the underlying platform's
* {@linkplain java.nio.charset.Charset#defaultCharset() default charset}.
* characters using the
* {@linkplain Charset#defaultCharset() default charset}.
*
* @param source A file to be scanned
* @throws FileNotFoundException if source is not found
* @see Charset#defaultCharset()
*/
public Scanner(File source) throws FileNotFoundException {
this((ReadableByteChannel)(new FileInputStream(source).getChannel()));
@ -702,13 +704,14 @@ public final class Scanner implements Iterator<String>, Closeable {
/**
* Constructs a new {@code Scanner} that produces values scanned
* from the specified file. Bytes from the file are converted into
* characters using the underlying platform's
* {@linkplain java.nio.charset.Charset#defaultCharset() default charset}.
* characters using the
* {@linkplain Charset#defaultCharset() default charset}.
*
* @param source
* the path to the file to be scanned
* @throws IOException
* if an I/O error occurs opening source
* @see Charset#defaultCharset()
*
* @since 1.7
*/
@ -769,10 +772,11 @@ public final class Scanner implements Iterator<String>, Closeable {
/**
* Constructs a new {@code Scanner} that produces values scanned
* from the specified channel. Bytes from the source are converted into
* characters using the underlying platform's
* {@linkplain java.nio.charset.Charset#defaultCharset() default charset}.
* characters using the
* {@linkplain Charset#defaultCharset() default charset}.
*
* @param source A channel to scan
* @see Charset#defaultCharset()
*/
public Scanner(ReadableByteChannel source) {
this(makeReadable(Objects.requireNonNull(source, "source")),