Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4833833

(spec) PrintWriter incorrectly describes character conversion

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 1.1
    • core-libs
    • Fix Understood
    • generic
    • generic

      Name: nl37777 Date: 03/17/2003


      The specifications of all PrintWriter.print methods say that text "is
      translated into bytes according to the platformÆs default character
      encoding, and these bytes are written in exactly the manner of the
      java.io.Writer.write(int) method."

      There are several problems with this:
      - PrintWriter doesn't do any character conversion itself. It formats a
      variety of data types and passes the resulting character sequences on to
      an underlying writer.
      - When eventually character conversion is performed, it may or may not
      use the default character encoding.
      - The java.io.Writer.write(int) method doesn't take bytes, it takes a
      Unicode character.
      - The print and write methods don't actually go through write(int); they
      use several different methods on the underlying writer, and according to
      the Writer class description the main bottleneck is the write(char[],
      int, int) method.

      A correct specification would be that the text "is written to the
      underlying Writer."
      ======================================================================

            Unassigned Unassigned
            nlindenbsunw Norbert Lindenberg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: