mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8276970: Default charset for PrintWriter that wraps PrintStream
Reviewed-by: rriggs, alanb
This commit is contained in:
parent
29e552c03a
commit
231fb61aae
4 changed files with 133 additions and 9 deletions
|
@ -99,7 +99,9 @@ public class OutputStreamWriter extends Writer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates an OutputStreamWriter that uses the default character encoding.
|
||||
* Creates an OutputStreamWriter that uses the default character encoding, or
|
||||
* where {@code out} is a {@code PrintStream}, the charset used by the print
|
||||
* stream.
|
||||
*
|
||||
* @param out An OutputStream
|
||||
* @see Charset#defaultCharset()
|
||||
|
@ -107,7 +109,7 @@ public class OutputStreamWriter extends Writer {
|
|||
public OutputStreamWriter(OutputStream out) {
|
||||
super(out);
|
||||
se = StreamEncoder.forOutputStreamWriter(out, this,
|
||||
Charset.defaultCharset());
|
||||
out instanceof PrintStream ps ? ps.charset() : Charset.defaultCharset());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue