8276188: Clarify "default charset" descriptions in String class

Reviewed-by: iris, joehw
This commit is contained in:
Naoto Sato 2021-11-02 16:08:11 +00:00
parent cd778f5b04
commit 495c828ae9

View file

@ -366,9 +366,8 @@ public final class String
*
* @deprecated This method does not properly convert bytes into characters.
* As of JDK 1.1, the preferred way to do this is via the
* {@code String} constructors that take a {@link
* java.nio.charset.Charset}, charset name, or that use the platform's
* default charset.
* {@code String} constructors that take a {@link Charset}, charset name,
* or that use the {@link Charset#defaultCharset() default charset}.
*
* @param ascii
* The bytes to be converted to characters
@ -428,9 +427,8 @@ public final class String
*
* @deprecated This method does not properly convert bytes into
* characters. As of JDK 1.1, the preferred way to do this is via the
* {@code String} constructors that take a {@link
* java.nio.charset.Charset}, charset name, or that use the platform's
* default charset.
* {@code String} constructors that take a {@link Charset}, charset name,
* or that use the {@link Charset#defaultCharset() default charset}.
*
* @param ascii
* The bytes to be converted to characters
@ -1385,9 +1383,9 @@ public final class String
/**
* Constructs a new {@code String} by decoding the specified subarray of
* bytes using the platform's default charset. The length of the new
* {@code String} is a function of the charset, and hence may not be equal
* to the length of the subarray.
* bytes using the {@link Charset#defaultCharset() default charset}.
* The length of the new {@code String} is a function of the charset,
* and hence may not be equal to the length of the subarray.
*
* <p> The behavior of this constructor when the given bytes are not valid
* in the default charset is unspecified. The {@link
@ -1415,9 +1413,9 @@ public final class String
/**
* Constructs a new {@code String} by decoding the specified array of bytes
* using the platform's default charset. The length of the new {@code
* String} is a function of the charset, and hence may not be equal to the
* length of the byte array.
* using the {@link Charset#defaultCharset() default charset}. The length
* of the new {@code String} is a function of the charset, and hence may not
* be equal to the length of the byte array.
*
* <p> The behavior of this constructor when the given bytes are not valid
* in the default charset is unspecified. The {@link
@ -1693,7 +1691,8 @@ public final class String
*
* @deprecated This method does not properly convert characters into
* bytes. As of JDK&nbsp;1.1, the preferred way to do this is via the
* {@link #getBytes()} method, which uses the platform's default charset.
* {@link #getBytes()} method, which uses the {@link Charset#defaultCharset()
* default charset}.
*
* @param srcBegin
* Index of the first character in the string to copy
@ -1780,7 +1779,8 @@ public final class String
/**
* Encodes this {@code String} into a sequence of bytes using the
* platform's default charset, storing the result into a new byte array.
* {@link Charset#defaultCharset() default charset}, storing the result
* into a new byte array.
*
* <p> The behavior of this method when this string cannot be encoded in
* the default charset is unspecified. The {@link