PrintWriter again
Oskar Liljeblad
osk@hem.passagen.se
Sat Aug 5 13:31:00 GMT 2000
OK, I've "complained" about java.io.PrintWriter before. This time I'm
not submitting a PR for it, instead I'd like to talk about it here.
According to the Sun JDK 1.3 api docs, println(whatever) in
PrintWriter should call print(whatever) and then println().
At least that's how I interpret the documentation:
"This method behaves as though it invokes print(boolean) and
then println()."
The reason for this is that it makes it easy for a subclass of
PrintWriter to catch all newline-writes by overriding a single method.
In my IndentWriter I buffer all non-newline terminated text, and
when println is called I format and finally print the buffered text.
The libgcj implementation of println(whatever) calls first
print(whatever) then the private method printlnUnsynchronized.
I would rather see it behave like the Sun implementation.
Oskar Liljeblad (osk@hem.passagen.se)
More information about the Java
mailing list