mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8260265: UTF-8 by Default
Reviewed-by: alanb, rriggs
This commit is contained in:
parent
32048536e9
commit
7fc8540907
22 changed files with 385 additions and 201 deletions
|
@ -118,11 +118,12 @@ public class PrintWriter extends Writer {
|
|||
* Creates a new PrintWriter, without automatic line flushing, from an
|
||||
* existing OutputStream. This convenience constructor creates the
|
||||
* necessary intermediate OutputStreamWriter, which will convert characters
|
||||
* into bytes using the default character encoding.
|
||||
* into bytes using the default charset.
|
||||
*
|
||||
* @param out An output stream
|
||||
*
|
||||
* @see java.io.OutputStreamWriter#OutputStreamWriter(java.io.OutputStream)
|
||||
* @see OutputStreamWriter#OutputStreamWriter(OutputStream)
|
||||
* @see Charset#defaultCharset()
|
||||
*/
|
||||
public PrintWriter(OutputStream out) {
|
||||
this(out, false);
|
||||
|
@ -132,14 +133,15 @@ public class PrintWriter extends Writer {
|
|||
* Creates a new PrintWriter from an existing OutputStream. This
|
||||
* convenience constructor creates the necessary intermediate
|
||||
* OutputStreamWriter, which will convert characters into bytes using the
|
||||
* default character encoding.
|
||||
* default charset.
|
||||
*
|
||||
* @param out An output stream
|
||||
* @param autoFlush A boolean; if true, the {@code println},
|
||||
* {@code printf}, or {@code format} methods will
|
||||
* flush the output buffer
|
||||
*
|
||||
* @see java.io.OutputStreamWriter#OutputStreamWriter(java.io.OutputStream)
|
||||
* @see OutputStreamWriter#OutputStreamWriter(OutputStream)
|
||||
* @see Charset#defaultCharset()
|
||||
*/
|
||||
public PrintWriter(OutputStream out, boolean autoFlush) {
|
||||
this(out, autoFlush, Charset.defaultCharset());
|
||||
|
@ -156,7 +158,7 @@ public class PrintWriter extends Writer {
|
|||
* {@code printf}, or {@code format} methods will
|
||||
* flush the output buffer
|
||||
* @param charset
|
||||
* A {@linkplain java.nio.charset.Charset charset}
|
||||
* A {@linkplain Charset charset}
|
||||
*
|
||||
* @since 10
|
||||
*/
|
||||
|
@ -172,9 +174,9 @@ public class PrintWriter extends Writer {
|
|||
/**
|
||||
* Creates a new PrintWriter, without automatic line flushing, with the
|
||||
* specified file name. This convenience constructor creates the necessary
|
||||
* intermediate {@link java.io.OutputStreamWriter OutputStreamWriter},
|
||||
* intermediate {@link OutputStreamWriter OutputStreamWriter},
|
||||
* which will encode characters using the {@linkplain
|
||||
* java.nio.charset.Charset#defaultCharset() default charset} for this
|
||||
* Charset#defaultCharset() default charset} for this
|
||||
* instance of the Java virtual machine.
|
||||
*
|
||||
* @param fileName
|
||||
|
@ -193,6 +195,7 @@ public class PrintWriter extends Writer {
|
|||
* If a security manager is present and {@link
|
||||
* SecurityManager#checkWrite checkWrite(fileName)} denies write
|
||||
* access to the file
|
||||
* @see Charset#defaultCharset()
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
|
@ -212,7 +215,7 @@ public class PrintWriter extends Writer {
|
|||
/**
|
||||
* Creates a new PrintWriter, without automatic line flushing, with the
|
||||
* specified file name and charset. This convenience constructor creates
|
||||
* the necessary intermediate {@link java.io.OutputStreamWriter
|
||||
* the necessary intermediate {@link OutputStreamWriter
|
||||
* OutputStreamWriter}, which will encode characters using the provided
|
||||
* charset.
|
||||
*
|
||||
|
@ -223,8 +226,7 @@ public class PrintWriter extends Writer {
|
|||
* written to the file and is buffered.
|
||||
*
|
||||
* @param csn
|
||||
* The name of a supported {@linkplain java.nio.charset.Charset
|
||||
* charset}
|
||||
* The name of a supported {@linkplain Charset charset}
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
* If the given string does not denote an existing, writable
|
||||
|
@ -251,7 +253,7 @@ public class PrintWriter extends Writer {
|
|||
/**
|
||||
* Creates a new PrintWriter, without automatic line flushing, with the
|
||||
* specified file name and charset. This convenience constructor creates
|
||||
* the necessary intermediate {@link java.io.OutputStreamWriter
|
||||
* the necessary intermediate {@link OutputStreamWriter
|
||||
* OutputStreamWriter}, which will encode characters using the provided
|
||||
* charset.
|
||||
*
|
||||
|
@ -262,7 +264,7 @@ public class PrintWriter extends Writer {
|
|||
* written to the file and is buffered.
|
||||
*
|
||||
* @param charset
|
||||
* A {@linkplain java.nio.charset.Charset charset}
|
||||
* A {@linkplain Charset charset}
|
||||
*
|
||||
* @throws IOException
|
||||
* if an I/O error occurs while opening or creating the file
|
||||
|
@ -281,9 +283,9 @@ public class PrintWriter extends Writer {
|
|||
/**
|
||||
* Creates a new PrintWriter, without automatic line flushing, with the
|
||||
* specified file. This convenience constructor creates the necessary
|
||||
* intermediate {@link java.io.OutputStreamWriter OutputStreamWriter},
|
||||
* intermediate {@link OutputStreamWriter OutputStreamWriter},
|
||||
* which will encode characters using the {@linkplain
|
||||
* java.nio.charset.Charset#defaultCharset() default charset} for this
|
||||
* Charset#defaultCharset() default charset} for this
|
||||
* instance of the Java virtual machine.
|
||||
*
|
||||
* @param file
|
||||
|
@ -302,6 +304,7 @@ public class PrintWriter extends Writer {
|
|||
* If a security manager is present and {@link
|
||||
* SecurityManager#checkWrite checkWrite(file.getPath())}
|
||||
* denies write access to the file
|
||||
* @see Charset#defaultCharset()
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
|
@ -313,7 +316,7 @@ public class PrintWriter extends Writer {
|
|||
/**
|
||||
* Creates a new PrintWriter, without automatic line flushing, with the
|
||||
* specified file and charset. This convenience constructor creates the
|
||||
* necessary intermediate {@link java.io.OutputStreamWriter
|
||||
* necessary intermediate {@link OutputStreamWriter
|
||||
* OutputStreamWriter}, which will encode characters using the provided
|
||||
* charset.
|
||||
*
|
||||
|
@ -324,8 +327,7 @@ public class PrintWriter extends Writer {
|
|||
* and is buffered.
|
||||
*
|
||||
* @param csn
|
||||
* The name of a supported {@linkplain java.nio.charset.Charset
|
||||
* charset}
|
||||
* The name of a supported {@linkplain Charset charset}
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
* If the given file object does not denote an existing, writable
|
||||
|
@ -363,7 +365,7 @@ public class PrintWriter extends Writer {
|
|||
* and is buffered.
|
||||
*
|
||||
* @param charset
|
||||
* A {@linkplain java.nio.charset.Charset charset}
|
||||
* A {@linkplain Charset charset}
|
||||
*
|
||||
* @throws IOException
|
||||
* if an I/O error occurs while opening or creating the file
|
||||
|
@ -580,11 +582,12 @@ public class PrintWriter extends Writer {
|
|||
/**
|
||||
* Prints a boolean value. The string produced by {@link
|
||||
* java.lang.String#valueOf(boolean)} is translated into bytes
|
||||
* according to the platform's default character encoding, and these bytes
|
||||
* according to the default charset, and these bytes
|
||||
* are written in exactly the manner of the {@link
|
||||
* #write(int)} method.
|
||||
*
|
||||
* @param b The {@code boolean} to be printed
|
||||
* @see Charset#defaultCharset()
|
||||
*/
|
||||
public void print(boolean b) {
|
||||
write(String.valueOf(b));
|
||||
|
@ -592,11 +595,12 @@ public class PrintWriter extends Writer {
|
|||
|
||||
/**
|
||||
* Prints a character. The character is translated into one or more bytes
|
||||
* according to the platform's default character encoding, and these bytes
|
||||
* according to the default charset, and these bytes
|
||||
* are written in exactly the manner of the {@link
|
||||
* #write(int)} method.
|
||||
*
|
||||
* @param c The {@code char} to be printed
|
||||
* @see Charset#defaultCharset()
|
||||
*/
|
||||
public void print(char c) {
|
||||
write(c);
|
||||
|
@ -605,12 +609,13 @@ public class PrintWriter extends Writer {
|
|||
/**
|
||||
* Prints an integer. The string produced by {@link
|
||||
* java.lang.String#valueOf(int)} is translated into bytes according
|
||||
* to the platform's default character encoding, and these bytes are
|
||||
* to the default charset, and these bytes are
|
||||
* written in exactly the manner of the {@link #write(int)}
|
||||
* method.
|
||||
*
|
||||
* @param i The {@code int} to be printed
|
||||
* @see java.lang.Integer#toString(int)
|
||||
* @see Charset#defaultCharset()
|
||||
*/
|
||||
public void print(int i) {
|
||||
write(String.valueOf(i));
|
||||
|
@ -619,12 +624,13 @@ public class PrintWriter extends Writer {
|
|||
/**
|
||||
* Prints a long integer. The string produced by {@link
|
||||
* java.lang.String#valueOf(long)} is translated into bytes
|
||||
* according to the platform's default character encoding, and these bytes
|
||||
* according to the default charset, and these bytes
|
||||
* are written in exactly the manner of the {@link #write(int)}
|
||||
* method.
|
||||
*
|
||||
* @param l The {@code long} to be printed
|
||||
* @see java.lang.Long#toString(long)
|
||||
* @see Charset#defaultCharset()
|
||||
*/
|
||||
public void print(long l) {
|
||||
write(String.valueOf(l));
|
||||
|
@ -633,12 +639,13 @@ public class PrintWriter extends Writer {
|
|||
/**
|
||||
* Prints a floating-point number. The string produced by {@link
|
||||
* java.lang.String#valueOf(float)} is translated into bytes
|
||||
* according to the platform's default character encoding, and these bytes
|
||||
* according to the default charset, and these bytes
|
||||
* are written in exactly the manner of the {@link #write(int)}
|
||||
* method.
|
||||
*
|
||||
* @param f The {@code float} to be printed
|
||||
* @see java.lang.Float#toString(float)
|
||||
* @see Charset#defaultCharset()
|
||||
*/
|
||||
public void print(float f) {
|
||||
write(String.valueOf(f));
|
||||
|
@ -647,12 +654,13 @@ public class PrintWriter extends Writer {
|
|||
/**
|
||||
* Prints a double-precision floating-point number. The string produced by
|
||||
* {@link java.lang.String#valueOf(double)} is translated into
|
||||
* bytes according to the platform's default character encoding, and these
|
||||
* bytes according to the default charset, and these
|
||||
* bytes are written in exactly the manner of the {@link
|
||||
* #write(int)} method.
|
||||
*
|
||||
* @param d The {@code double} to be printed
|
||||
* @see java.lang.Double#toString(double)
|
||||
* @see Charset#defaultCharset()
|
||||
*/
|
||||
public void print(double d) {
|
||||
write(String.valueOf(d));
|
||||
|
@ -660,11 +668,12 @@ public class PrintWriter extends Writer {
|
|||
|
||||
/**
|
||||
* Prints an array of characters. The characters are converted into bytes
|
||||
* according to the platform's default character encoding, and these bytes
|
||||
* according to the default charset, and these bytes
|
||||
* are written in exactly the manner of the {@link #write(int)}
|
||||
* method.
|
||||
*
|
||||
* @param s The array of chars to be printed
|
||||
* @see Charset#defaultCharset()
|
||||
*
|
||||
* @throws NullPointerException If {@code s} is {@code null}
|
||||
*/
|
||||
|
@ -675,11 +684,12 @@ public class PrintWriter extends Writer {
|
|||
/**
|
||||
* Prints a string. If the argument is {@code null} then the string
|
||||
* {@code "null"} is printed. Otherwise, the string's characters are
|
||||
* converted into bytes according to the platform's default character
|
||||
* encoding, and these bytes are written in exactly the manner of the
|
||||
* converted into bytes according to the default charset,
|
||||
* and these bytes are written in exactly the manner of the
|
||||
* {@link #write(int)} method.
|
||||
*
|
||||
* @param s The {@code String} to be printed
|
||||
* @see Charset#defaultCharset()
|
||||
*/
|
||||
public void print(String s) {
|
||||
write(String.valueOf(s));
|
||||
|
@ -688,12 +698,13 @@ public class PrintWriter extends Writer {
|
|||
/**
|
||||
* Prints an object. The string produced by the {@link
|
||||
* java.lang.String#valueOf(Object)} method is translated into bytes
|
||||
* according to the platform's default character encoding, and these bytes
|
||||
* according to the default charset, and these bytes
|
||||
* are written in exactly the manner of the {@link #write(int)}
|
||||
* method.
|
||||
*
|
||||
* @param obj The {@code Object} to be printed
|
||||
* @see java.lang.Object#toString()
|
||||
* @see Charset#defaultCharset()
|
||||
*/
|
||||
public void print(Object obj) {
|
||||
write(String.valueOf(obj));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue