Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are System.out/err implemented as Byte Streams in Java?

Tags:

java

iostream

I was having a look at this tutorial at Sun on command line I/O. It stated that:

You might expect the Standard Streams to be character streams, but, for historical reasons, they are byte streams. System.out and System.err are defined as PrintStream objects. Although it is technically a byte stream, PrintStream utilizes an internal character stream object to emulate many of the features of character streams.

Does any one know what "the historical reasons" are?

like image 300
hhafez Avatar asked May 21 '26 12:05

hhafez


1 Answers

The "historical reasons" are that character streams did not exist in Java 1.0. Apparently Sun realized that the character translation model was insufficient and the Character oriented Reader/Writer class hierarchy was added in Java 1.1.

But it was too late for System.out and friends.

like image 173
Darron Avatar answered May 23 '26 03:05

Darron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!