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."
======================================================================
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."
======================================================================
- relates to
-
JDK-4916565 (spec) PrintStream does not document use of charset consistently
-
- Open
-
-
JDK-8254653 PrintStream and PrintWriter platform encoding mention is incorrect
-
- Open
-