Lackadaisical One-to-One between Char and Byte Streams

Posted by Vaibhav Bajpai on Stack Overflow See other posts from Stack Overflow or by Vaibhav Bajpai
Published on 2010-05-25T11:40:50Z Indexed on 2010/05/25 12:11 UTC
Read the original article Hit count: 284

Filed under:
|
|

I expected to have a one-to-one correspondence between the character streams and byte streams in terms of how the classes are organized in their hierarchy.

FilterReader and FilterWriter (character streams) correspond back to FilterInputStream and FilterOutputStream (byte stream) classes.

However I noticed few changes as -

  • BufferedInputStream extends FilterInputStream, but BufferedReader does NOT extend FilterReader.

  • BufferedOutputStream and PrintStream both extend FilterOutputStream, but BufferedWriter and PrintWriter does NOT extend FilterWriter.

  • FilterInputStream and FilterOutputStream are not abstract classes, but FilterReader and FilterWriter are.

I am not sure if I am being too paranoid to point out such differences, but was just curious to know if there was design reasoning behind such decision.

© Stack Overflow or respective owner

Related posts about java

Related posts about design-patterns