-
Sub-task
-
Resolution: Delivered
-
P4
-
18
-
generic
-
generic
-
Verified
The `java.io.PrintStream`, `PrintWriter`, and `OutputStreamWriter` constructors that take a `java.io.OutputStream` and no charset now inherit the charset when the output stream is a `PrintStream`. This is important for usages such as:
```
new PrintWriter(System.out)
```
where it would be problematic if `PrintStream` didn't use the same charset as that used by `System.out`. This change was needed because [JEP 400](https://openjdk.java.net/jeps/400) makes it is possible, especially on Windows, that the encoding of `System.out` is not UTF-8. This would cause problems if `PrintStream` were wrapped with a `PrintWriter` that used UTF-8.
As part of this change, `java.io.PrintStream` now defines a `charset()` method to return the print stream's charset.
```
new PrintWriter(System.out)
```
where it would be problematic if `PrintStream` didn't use the same charset as that used by `System.out`. This change was needed because [JEP 400](https://openjdk.java.net/jeps/400) makes it is possible, especially on Windows, that the encoding of `System.out` is not UTF-8. This would cause problems if `PrintStream` were wrapped with a `PrintWriter` that used UTF-8.
As part of this change, `java.io.PrintStream` now defines a `charset()` method to return the print stream's charset.