Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8276970 Default charset for PrintWriter that wraps PrintStream
  3. JDK-8277357

Release Note: Default charset for PrintWriter that wraps PrintStream

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Resolved
    • Priority: P4
    • Resolution: Delivered
    • Affects Version/s: 18
    • Fix Version/s: 18
    • Component/s: core-libs
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      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 the `PrintStream` didn't use the same charset as that used by `System.out`. This change was motivated by JEP 400 where it is possible, especially on Windows, that the encoding of `System.out` is not UTF-8, in which case it would be very problematic if it were wrapped with a `PrintWriter` that uses UTF-8.

      As part of this change, `java.io.PrintStream` now defines a `charset()` method to return the print stream's charset.

        Attachments

          Activity

            People

            Assignee:
            naoto Naoto Sato
            Reporter:
            naoto Naoto Sato
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: